How to refresh datagridview when closing child form?

后端 未结 4 1112
南方客
南方客 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 18:21

    You're creating a new instance of the main form which isn't effecting the actual main form instance. What you need to do is, call the code on the main form itself, just like the code you say works on the button click:

    private void frmNew_FormClosing(object sender, FormClosingEventArgs e)
    {
        this.itemCategoryBindingSource.EndEdit();
        this.itemsTableAdapter.Fill(myDatabaseDataSet.Items);
        this.dataGridView1.Refresh();
    }
    

提交回复
热议问题