winforms - How to call the mainwindow object from a second object created from main window in c# .net -


being first user in windows form development want ask simple question ...

i created form(mainwindow.cs) within solution opens @ time of running solution.

latter created second form(secondwindow.cs) , created event can called first window clicking button.when second window loded first window(mainwindow.cs) disabled.

now want enable mainwindow.cs when second window closed.

how that...

a simple solution have hide mainwindow.cs , latter on closing second window make new object of first window , show it.but not way think because there object created .net framework first window automatically, why should create new object of mainwindow.cs .

code of first window ( mainwindow.cs ) :

private void pricecontrolltoolstripmenuitem_click(object sender, eventargs e)     {        secondwindow price = new secondwindow();         this.enabled = false;         price.show();     } 

code of second window ( on closing secondwindow.cs )

private void price_controll_formclosed(object sender, formclosedeventargs e)     {         // goes here make mainwindow.cs enable state     } 

you can pass main form owner second form

private void pricecontrolltoolstripmenuitem_click(object sender, eventargs e) {     secondwindow price = new secondwindow() { owner = };     this.enabled = false;     price.show(); } 

then can reference second form.

private void price_controll_formclosed(object sender, formclosedeventargs e) {     owner.enabled = true; } 

Comments

Popular posts from this blog

html5 - What is breaking my page when printing? -

c# - must be a non-abstract type with a public parameterless constructor in redis -

ajax - PHP/JSON Login script (Twitter style) not setting sessions -