datagrid access from another form

后端 未结 3 1529
梦如初夏
梦如初夏 2021-01-27 12:37

I have datagridview in form1. How can I access datagridview from form2.

  private void button1_Click(object sender, EventArgs e)
  {
          string sql1 = \"in         


        
3条回答
  •  一生所求
    2021-01-27 13:27

    In Form2:

    public DataGridView Dgv { get; set; }
    

    In Form1:

    Form2 f = new Form2();
    f.Dgv = mainframe.Dgv;
    

    In Form2 access its own Dgv propety.

提交回复
热议问题