c# - Access form control from other form -
this question has answer here:
- access class form 3 answers
i got following method in mdiparent1
public void disablebutton() { toolstripbutton1.enabled = false; }
in loginform okbutton click
mdiparent1 f1 = new mdiparent1(); f1.disablebutton(); this.close();
the loginform modal of mdiparent1.
problem disablebutton() don't works in loginform
you're creating new instance of mdiparent1
, not using actual instance opened loginform
. pass parent loginform
constructor.
private mdiparent1 _parentform = null; public loginform(mdiparent1 parentform) { _parentform = parentform; } //then in whichever event you're using _parentform.disablebutton(); this.close();
when want show loginform
form, pass in mdiparent1
form.
//assuming in mdiparent1.cs (otherwise pass form instance variable) using(loginform lf = new loginform(this)) { lf.show(); }
Comments
Post a Comment