473,396 Members | 1,754 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

ProgressBar incremented from outside of Form

I have, the following question:

I have a WindowsForm with ProgressBar progressBar1 and Button button1.
After onClick event on button the following method executes:

button_Click(object sender, EventArgs e)
{
DatabaseOperations.ClearDatabase();
}

where ClearDatabase() is static method which should increment my
progress bar. How can I increment my progress bar without giving
ProgressBar object as parameter( I mean without using
ClearDatabase(progressBar1); - it doesn't seem to be a good way)

Thanks for any reply.

Nov 29 '06 #1
5 2461
<ma***@o2.plwrote:
I have, the following question:

I have a WindowsForm with ProgressBar progressBar1 and Button button1.
After onClick event on button the following method executes:

button_Click(object sender, EventArgs e)
{
DatabaseOperations.ClearDatabase();
}

where ClearDatabase() is static method which should increment my
progress bar. How can I increment my progress bar without giving
ProgressBar object as parameter( I mean without using
ClearDatabase(progressBar1); - it doesn't seem to be a good way)
You'll need to provide *something*. If you want to decouple
DatabaseOperations from the UI (which is reasonable) you could give
DatabaseOperations a DatabasedClearProgress event which the UI could
subscribe to, and which ClearDatabase could raise.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too
Nov 29 '06 #2
You'll need to provide *something*. If you want to decouple
DatabaseOperations from the UI (which is reasonable) you could give
DatabaseOperations a DatabasedClearProgress event which the UI could
subscribe to, and which ClearDatabase could raise.

But how can I raise ProgressBar event from this static method?

Nov 30 '06 #3
<ma***@o2.plwrote:
You'll need to provide *something*. If you want to decouple
DatabaseOperations from the UI (which is reasonable) you could give
DatabaseOperations a DatabasedClearProgress event which the UI could
subscribe to, and which ClearDatabase could raise.

But how can I raise ProgressBar event from this static method?
You'd make the DatabaseClearProgress event static as well. It wouldn't
be a ProgressBar event - it would just be that the handler the UI added
would happen to update the progress bar.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too
Nov 30 '06 #4
ma***@o2.pl wrote:
I have, the following question:

I have a WindowsForm with ProgressBar progressBar1 and Button button1.
After onClick event on button the following method executes:

button_Click(object sender, EventArgs e)
{
DatabaseOperations.ClearDatabase();
}

where ClearDatabase() is static method which should increment my
progress bar. How can I increment my progress bar without giving
ProgressBar object as parameter( I mean without using
ClearDatabase(progressBar1); - it doesn't seem to be a good way)
I think the issue is that ClearDatabase() should probably NOT be static. You
could create a database "engine" and then have an event on it to indicate
status, completion, what have you. Then subscribe to them from your UI and
have the event handler post to the progress bar.

--
Thomas T. Veldhouse
Key Fingerprint: D281 77A5 63EE 82C5 5E68 00E4 7868 0ADC 4EFB 39F0
Nov 30 '06 #5
Thomas T. Veldhouse <ve*****@yahoo.comwrote:
I think the issue is that ClearDatabase() should probably NOT be static. You
could create a database "engine" and then have an event on it to indicate
status, completion, what have you. Then subscribe to them from your UI and
have the event handler post to the progress bar.
While I agree that it would be good to have a database engine instance,
there's nothing to stop the OP from having a static event.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too
Nov 30 '06 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Job Lot | last post by:
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...
1
by: Geir Baardsen | last post by:
Hi! Is there any clear examples on how to use the Progressbar (6.0) in ms access 2000 anywhere? Me.Name
8
by: needin4mation | last post by:
Please consider: foreach (ListViewItem item in listViewFiles.Items) { // Display the ProgressBar control. pBar1.Visible = true; // Set Minimum to 1 to represent the first file being copied....
1
by: Mehr H | last post by:
I've been trying to figure out how i can embed a Windows.Forms.ProgressBar in my webform (aspx) file. I have tried putting a Windows.Forms.ProgressBar as public on a regular winform designer form...
2
by: Steven Smith | last post by:
is it possible to change the color of the step blocks from the default blue which are incremented in the progressbar control or is this goverened by windows ? I tried ...
2
by: sotto | last post by:
I need a loginscreen, that will show a progressbar that changes values based on a method in the main application (loading data from database) how would i do this? (i guess i need threading for...
2
by: =?Utf-8?B?QWFyb24=?= | last post by:
Since some controls such as the DataGridView take a long time to update themselves when performing certain tasks, I have added a StatusStrip with a ProgressBar on it. While I am updating the...
1
Kermit
by: Kermit | last post by:
Hi. I've searched the forum for answer, but haven't found one. The problem is with displaying the label. When the progressBar is incremented I change the text of the Label, but it doesn't...
6
by: JB | last post by:
Hi All, I have a Windows Form application that shows a "please wait" form while I query a database for various information. I display my form using Show, then run my DB query, then Close the...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.