title: How Do I Apply Validation To Form
body: <p>I have a requirement where I need to do Find and Replace in datagridview for multiple pages - it's working fine. The problem is, after I find a specific word and replace it and again if I click on Find and Replace button, the earlier find and replace values are gone. </p>
  
  <p>How to work on it?</p>
  
  <p>The code is provided below:</p>
  
  <pre><code>public string toFind = "";
  public string toReplace = "";
  
  private void btnFindandReplace_Click(object sender, EventArgs e)
  {
      Form2 f = new Form2();
      f.cmbColumnCombo.DataSource = cmbList;
      f.ShowDialog();
      toFind = f.txtfind.Text;
      toReplace = f.txtreplace.Text;
  
      for (int i = 0; i &lt;= dataGridView1.Rows.Count - 1; i++)
      {
          if (dataGridView1.Rows[i].Cells[f.cmbColumnCombo.Text].Value.ToString().ToLower().Contains(f.txtfind.Text.ToLower()))
          {
              if (!string.IsNullOrEmpty(f.txtfind.Text))
              {
                  dataGridView1.Rows[i].Cells[f.cmbColumnCombo.Text].Value =
                      dataGridView1.Rows[i].Cells[f.cmbColumnCombo.Text].Value.ToString().Replace(f.txtfind.Text, f.txtreplace.Text);
              }
          }
      }
  }
  </code></pre>