2
Answers

Remove whitespace from middle of string in datagrid

mike Delvotti

mike Delvotti

12y
3.1k
1
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

Answers (2)