I have a form Form1 from which I show Form2 as a modal form. From Form2 I do all kinds of editing and deleting various values ββthat should be reflected in Form1 after closing Form2 . So what I do is RePopulateControls_in_Form1() after closing Form2 . Since RePopulateControls_in_Form1() is a long process, I want to execute this method only if any modification (change, add, delete) occurs in Form2 , and not when Form2 just been opened and closed.
So here is what I am trying to do in Form1 :
Form2 f = new Form2(); if (f.ShowDialog(this) == DialogResult.Something) RePopulateControls_in_Form1()
And then in Form2 I,
private void bntEdit() {
But my problem is .Something . If it's nothing but .None , Form2 just closes. I do not want Form2 just close unless the user has closed it.
If I do this:
//in Form1 private void Form1_Click() { Form2 f = new Form2(); if (f.ShowDialog(this) == DialogResult.None) RePopulateControls_in_Form1() } //in Form2 private void Form2_SomeModification() { //If Modified? this.DialogResult = DialogResult.None; }
RePopulateControls_in_Form1() did not hit!
In short, in my program, how can I tell the compiler to call RePopulateControls_in_Form1() only if the values ββare changed in Form2 ?
Note. Recompilation is certainly required, because the controls are dynamically created and a bit complicated (in fact, what is created in Form2 is the controls of the graphical interface and its labels, etc.).
source share