c# - Access form control from other form -


this question has answer here:

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

Popular posts from this blog

curl - PHP fsockopen help required -

HTTP/1.0 407 Proxy Authentication Required PHP -

c# - Resource not found error -