title: C# DataGridView: How to change a single cell value
body: <p>I have 2 forms. First form contains the datagridview and on the second form the users can change a single value in the datagridview in first form. The problem is if the user changes a value, the same value in other cells are changed too.</p>
  
  <p>Ex) Before:</p>
  
  <blockquote>
    <p>A B B C D</p>
    
    <p>B B C D E</p>
  </blockquote>
  
  <p>After(If I would try to change only one B after A to Z, it will change all Bs):</p>
  
  <blockquote>
    <p>A Z Z C D</p>
    
    <p>Z Z C D E</p>
  </blockquote>
  
  <p>Form 1:</p>
  
  <pre><code>private void callForm2(object sender, EventArgs e)
  {
      Form2 f2 = new Form2();
      f2.Show();
      f2.Text = this.dataGridView1.CurrentCell.Value.ToString();
  }
  </code></pre>
  
  <p>Form 2:</p>
  
  <pre><code>private void button1_Click(object sender, EventArgs e)
  {
      string edit = File.ReadAllText(@"C:\Master.txt");
      edit = edit.Replace(Text, textBox1.Text); //first Text = old value, textBox1 = new value
      File.WriteAllText(@"C:\Master.txt", edit);
      string message = "Item is modified on the list!";
      string caption = "Success";
      MessageBoxButtons button = MessageBoxButtons.OK;
      MessageBoxIcon icon = MessageBoxIcon.Information;
      MessageBox.Show(message, caption, button, icon);
      this.Close();
      //Changes Successfully, but if the cell value is same it changes all the same values
  }
  </code></pre>
  
  <p>The Form 1 gets the data from a text file</p>
  
  <pre><code>private void button1_Click(object sender, EventArgs e)  //Add txt to program
  {
      if (File.Exists(@"C:\Master.txt"))    //Look fot txt
      {
          using (StreamReader master = File.OpenText(@"C:\Master.txt")) //txt to table
          {
              int row = 0;
              string s = String.Empty;
              while ((s = master.ReadLine()) != null)
              {
                  string[] columns = s.Split(',');
                  dataGridView1.Rows.Add();
                  for (int i = 0; i &lt; columns.Length; i++)
                  {
                      dataGridView1[i, row].Value = columns[i];
                  }
                  row++;
              }
          }
      }
      else
      {
          string message = "Program was not able to find the text file.";
          string caption = "Failed";
          MessageBoxButtons button = MessageBoxButtons.OK;
          MessageBoxIcon icon = MessageBoxIcon.Warning;
          MessageBox.Show(message,caption,button,icon);
      }
  }
  </code></pre>