I am trying to search and replace a specific text in all the rows.I have managed to search the text in all the rows and display it accordingly but i don't know what to do with replacing.I have tries this but it doesn't seen to work.Here is the code.
private void button7_Click_3(object sender, EventArgs e)
{
string filterBy;
filterBy = "Stringtext Like '%" + textBox6.Text + "%'";
((DataTable)dataGridView1.DataSource).DefaultView.RowFilter = filterBy;
int rows = dataGridView1.Rows.Count;
for (int i = 0; i < rows-1; i++)
{
dataGridView1[2, i].Value.ToString().Replace(textBox6.Text, textBox7.Text);
}
dataGridView1.Refresh();
}
Try this in the loop:
dataGridView1[2, i].Value = dataGridView1[2, i].Value.ToString().Replace(textBox6.Text, textBox7.Text);