Categories: MSDN / DotNet / Java / Scripts / Linux / PHP Ask - La ask - La Answer

Should be easy one to answer!

Hello,
I have a WinApp and my main form creates an instance of a class, this class
does some processing, I want to access the Forms, progress bar.
How do I ref teh form from the class?
Thanks
Michael
[234 byte] By [Michael] at [2007-11-9 18:50:34]
# 1 Re: Should be easy one to answer!
It's best not to access the progress bar directly from outside the form.
Instead, write methods in your form class that provide outside agents with
the appropriate level of functionality. For example:

public void setProgressBar(int percent)
{
if ((percent >= 0) && (percent <= 100))
{
this.progressBar1.Value = percent;
}
}

Now you can pass a reference to the form when you create the class instance,
which can use that reference to set the progress bar in the form.

"Michael" <mrwassermann@att.net> wrote in message
news:3f574eac@tnews.web.dev-archive.com...
>
> Hello,
>
> I have a WinApp and my main form creates an instance of a class, this
class
> does some processing, I want to access the Forms, progress bar.
>
> How do I ref teh form from the class?
>
> Thanks
> Michael
Russell Jones at 2007-11-11 21:57:59 >