How to refresh datagridview when closing child form?

后端 未结 4 1101
南方客
南方客 2020-12-02 17:31

I\'ve a dgv on my main form, there is a button that opens up another form to insert some data into the datasource bounded to the dgv. I want when child form closes the dgv a

4条回答
  •  温柔的废话
    2020-12-02 17:58

    Great answer there! The other method would have been:

    1. Check if the form you want to update is open.
    2. Call the method to refresh your gridVieW.

      **inside your refreshMethod() in form1 make sure you set the datasource to null **

     if (System.Windows.Forms.Application.OpenForms["Form1"]!=null)
                {
                    (System.Windows.Forms.Application.OpenForms["Form1"] as Form1).refreshGridView("");
                }

提交回复
热议问题