Share This!

Thursday, January 2, 2014

How to access your Main Form from a Static Method

Of course the right way is to pass a handle to the form if it is needed in the static method.

public static void Import(MainForm parent)
{
    parent.whatever();
}
But in my case I just didn't want to pass that handle around - and my application only had one form, so...

Application.OpenForms[0].Refresh();


...

Bryan Valencia is a contributing editor and founder of Visual Studio Journey.  He owns and operates Software Services, a web design and hosting company in Manteca, California.

No comments:

Post a Comment

Contact Us

Name

Email *

Message *