Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Progressbar on the Main form 1

Status
Not open for further replies.

RyanEK

Programmer
Apr 30, 2001
323
0
0
AU
Hi,

Looking for the best approach to this problem :)
Lets say I have a Main form that contains a progressbar.

From the Main form I can create Form1.
From Form1 I can create Form2.
From from Form2 I can create Form3.

What is the best method to update the progress bar from any of the subforms?

A star for any helpful answer :)

Thanks
Ryan


 
this is purely theoretical...

a progress bar would have event(s) to manage the state of the progress. Most likely something along the lines of ProgressBarChanged event.

so you would need to associate a ProgressBarChanged event handler (located on forms 1, 2 & 3) to the progress bar itself (on form 1).

there are 2 approaches to this technique.
1. brute force
Code:
Form1.ProgressBar.ProgressBarChanged += Form1.Form2.EvnetHandler;
Form1.ProgressBar.ProgressBarChanged += Form1.Form2.Form3.EventHandler;

and
Form1.ProgressBar.ProgressBarChanged -= Form1.Form2.EvnetHandler;
Form1.ProgressBar.ProgressBarChanged -= Form1.Form2.Form3.EventHandler;
2. using encapsulation and other common design principles. With this technique your creativity is the only limitation for what the code may look like. This gets into concepts like Program to the Interface, Dependency Inversion, Encapsulation, Single Responsibilty, etc.

Jason Meckley
Programmer
Specialty Bakers, Inc.

faq855-7190
 
Using brute force like the one you mentioned was the path I was taking until I realised it was a little cumbersome. I posted hoping there was a better way. Thanks for you suggestions.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top