I have a GridView
in Liste_Form and button in Close_Form.
How can I refresh the Gridview
in Liste_Form, when i click the button on Close_Form?
Or reload the Liste_Form.
I have a GridView
in Liste_Form and button in Close_Form.
How can I refresh the Gridview
in Liste_Form, when i click the button on Close_Form?
Or reload the Liste_Form.
You have a few ways this can be done. One way I might suggest is passing a delegate to the second form in the constructor:
Form2 myForm2 = new Form2(RefreshGrid); // assign to a Form2 local variable
...where in Form1 (the grid owner) you have defined the RefreshGrid
method:
void RefreshGrid(){
// perform grid refresh
}
...so that in myForm2
you can execute the action when the button is clicked:
void OnButtonClicked(object sender, EventArgs e){
refreshAction();
}
Define event on Close_Form (of course consider better name for event):
public event EventHandler SomethingHappened;
Raise this event inside button click event handler:
private void Button_Click(object sender, EventArgs e)
{
if (SomethingHappened != null)
SomethingHappened(this, EventArgs.Empty);
}
Subscribe to this event on Liste_Form:
Close_Form closeForm = new Close_Form();
closeForm.SomethingHappened += Close_Form_SomethingHappened;
Refresh your list in this event handler:
private void Close_Form_SomethingHappened(object sender, EventArgs e)
{
// refresh GridView
}