Feroz Khan

Feroz Khan

  • 1.4k
  • 300
  • 91.5k

How can i update DataGrid view value from another form textbox value

Feb 2 2023 1:16 PM

Dear All, 

Please need your support i am trying to update datagriviwe from another form textbox but cannot please need your support.

Below for you refrence.

private void btntupdate_modify_Click(object sender, EventArgs e)
{
    try
    {
        POS form1 = new POS();
        DataGridView Main_dg = (DataGridView)form1.Controls["dataGridView1"];
        for (int i = 0; i < Main_dg.Rows.Count; i++)
        {
            Main_dg.Rows[i].Cells[2].Value = txtupdate_grampcs.Text;
            Main_dg.Rows[i].Cells[3].Value = txtupdate_unitprice.Text;
            Main_dg.Rows[i].Cells[4].Value = txtupdate_total.Text;
        }
    }
    catch (Exception ex)
    {
        MessageBox.Show(ex.Message);
    }
}

Answers (2)