Hi

How can I get a handle to a currently loaded form instance and use that to
call one of form's methods?

Thanks

Re: Accessing a loaded form by rowe_newsgroups

rowe_newsgroups
Fri Mar 14 10:06:33 CDT 2008

On Mar 14, 9:44 am, "John" <J...@nospam.infovis.co.uk> wrote:
> Hi
>
> How can I get a handle to a currently loaded form instance and use that to
> call one of form's methods?
>
> Thanks

You will need to hold a reference to it (a variable etc). Another
option, if the form is only ever going to be used once at any given
time, is to create the form class as a singleton and access it that
way.

http://en.wikipedia.org/wiki/Singleton_pattern
http://www.yoda.arachsys.com/csharp/singleton.html

Thanks,

Seth Rowe [MVP]

Re: Accessing a loaded form by John

John
Fri Mar 14 11:09:33 CDT 2008

The form is the main form of my app and it has a status bar. I need to
display text in status bar from various subs in modules outside of the form.
What is the best mechanism?

Thanks

Regards

"rowe_newsgroups" <rowe_email@yahoo.com> wrote in message
news:4d152f84-d114-4354-9b5e-3c36660d39b7@n77g2000hse.googlegroups.com...
> On Mar 14, 9:44 am, "John" <J...@nospam.infovis.co.uk> wrote:
>> Hi
>>
>> How can I get a handle to a currently loaded form instance and use that
>> to
>> call one of form's methods?
>>
>> Thanks
>
> You will need to hold a reference to it (a variable etc). Another
> option, if the form is only ever going to be used once at any given
> time, is to create the form class as a singleton and access it that
> way.
>
> http://en.wikipedia.org/wiki/Singleton_pattern
> http://www.yoda.arachsys.com/csharp/singleton.html
>
> Thanks,
>
> Seth Rowe [MVP]



Re: Accessing a loaded form by Armin

Armin
Fri Mar 14 11:33:45 CDT 2008

"John" <John@nospam.infovis.co.uk> schrieb
> The form is the main form of my app and it has a status bar. I need
> to display text in status bar from various subs in modules outside
> of the form. What is the best mechanism?

If the code in the modules refer to the Form, you should move the code
from the modules into the Form. Without the Form, the code won't run
anyway.

If you want to write more abstract code, you can cut the relation to the
Form. Instead, declare and raise an event in the Module. The Form can
catch the event and update the statusbar.

Be aware that long running code makes the UI inoperatable. Even short
running code can lead to inoperatable ghost windows that don't reflect
changes in your status bar. In this case you should consider executing
the code in another thread.


Armin