Guys, I'm trying to remove the whitespace in the middle of a string within a datagridview cell, i think i'm close with the below but it doesn't do anything?
foreach (DataGridViewRow row in dataGridView1.Rows)
{
if (row.IsNewRow) break;
object obj = row.Cells[8].Value;
{
string trim = Regex.Replace(Text, @"\s+", " ").Trim();
}
}
so i want the output in row.cells[8] to change from this: 123 456 to end up as this: 123456
Loading
VulpesPosted Mar 28, 2012, 4:48 AM
foreach (DataGridViewRow row in dataGridView1.Rows)
{
if (row.IsNewRow) break;
object obj = row.Cells[8].Value;
if (obj != null) row.Cells[8].Value = Regex.Replace(obj.ToString(), @"\s+", "").Trim();
}
mike DelvottiPosted Mar 28, 2012, 5:06 AM