There are many ways to do this of course, but I prefer to use
delegates/events. Off the top of my head, here is a brief explanation on
how to do it:
Somewhere in the namespace or within a class, declare a public delegate that
defines what the method signature looks like:
public delegate void ProgressEventHa ndler(int percentComplete );
Then, in your data module (class), do something like this:
public MyDataClass
{
public event ProgressEventHa ndler OnProgress;
....
// fire the event at whatever point you want to..say in this method
public void DoSomeWork()
{
// do some work...then fire the event
if (OnProgress != null)
{
OnProgress(mypr ogresspercent);
}
}
}
Then, in your main form, you define the method to handle the event:
MyDataClass myDataClass = new MyDataClass();
myDataClass.OnP rogress += new ProgressEventHa ndler(MyProgres sHandler);
...
private void MyProgressHandl er(int percentComplete )
{
// update your progress bar here.
}
Hopefully the above makes sense :) Anyway, I recommend you do a little
research on delegates and events and see what they have to offer. In the
end, they are more flexible than other paradigms.
-sb
"Job Lot" <Jo****@discuss ions.microsoft. com> wrote in message
news:C3******** *************** ***********@mic rosoft.com...
I have a module which performs data processing job and as each row is
processed progress bar value is incremented. Now I have moved this module
in
a separate class. How can I increment the value progress bar which resides
on
the main form?
Do I have to pass the progress bar to my class, or there's some other way?