Cor4Ever
Cor4Ever

Reputation: 229

Progress bar before main form

I have written an application that scans the network then populates a Listbox with all the information, the discovery process takes a little while to complete as expected because the number of network devices we currently have; I would like to display so sort of progress bar to let the users know that the network is being scan but I have no idea how to do that, can you guys please point me in the right direction? I was thinking about creating a small form dynamically and then populate it with the progress bar but I am so lost at this point. Thank you.

Upvotes: 1

Views: 642

Answers (2)

David Cornelius
David Cornelius

Reputation: 447

You question implies the network scanning is taking place as the first thing when the program launches instead of when a user clicks a button on the form, like in the FormCreate event. If this is what you're doing, you might consider putting the network scanning code into a thread and launching the thread when the main form starts. That way, the users will actually see the form and you can send the form ProgressBar or status updates from the thread.

An easier way to do this is to put a Timer on the form and in the FormCreate or FormActivate start the timer. The timer's OnTimer event will then start the network scanning and from there you can update a ProgressBar or send status messages to a ListBox or whatever.

Upvotes: 1

Jim McKeeth
Jim McKeeth

Reputation: 38703

You can just put the progress bar on the same form as your ListBox.

Displaying progress is an artform. If you know how many network devices you are going to scan ahead of time, then set the Max to that number. Then as you are updating the ListBox check you can also update the Position of the progress bar if you are on the next Network Device.

You can also use two progress bars - one for the number of network devices, and the second for the current network device. Also you can update the Max as you discover more to scan.

The problem comes with the fact that you may not know how many network devices when you start, or the last device may take longer to scan then all the previous devices put together. In that case you can just use a strobe progress bar, which bounces back and forward. You can have that update when you update the ListBox, or have it update on a timer. This really just lets the user know you are busy and have not locked up.

If you want to keep the user from clicking controls while you are in process then you can just disable those controls.

Upvotes: 1

Related Questions