-
Mar 2nd, 2016, 05:27 PM
#1
Thread Starter
New Member
Progress in Listbox step by step.
Hello, I want my users to follow the progress of my table backups in a listbox here is the code.
Private Sub Button2_Click(sender As System.Object, e As System.EventArgs) Handles Button2.Click
Me.Cursor = Windows.Forms.Cursors.WaitCursor
ListBox1.Items.Add("Backup articles...")
Backup_Article()
Me.Cursor = Windows.Forms.Cursors.Default
ListBox1.Items.Add("Backup articles OK.")
ListBox1.Items.Add("Backup layout...")
Backup_Layout()
ListBox1.Items.Add("Backup layout OK.")
ListBox1.Items.Add("Backup klanten...")
Backup_klanten()
ListBox1.Items.Add("Backup klanten OK.")
End Sub
(The Backup_XX() are private Sub routines.) But the listbox fills only at the end of all routines... Not when one routine in finished...
How can I inform my user step by step?
Greetings,
Koen
-
Mar 2nd, 2016, 05:41 PM
#2
Re: Progress in Listbox step by step.
Actually, it does fill it as it goes... What's happening is that the process is relatively quick. UI updates are a low-priority message, so the screen doesn't really get the chance to update and show the progress until the process it done.
Try a Listbox1.Invalidate (I think that's the right method) after the Items.Add calls... that will invalidate the listbox's UI and force a refresh... it may flicker a little bit, not much can be done about that.
-tg
-
Mar 2nd, 2016, 06:17 PM
#3
Re: Progress in Listbox step by step.
It's Listbox1.Refresh that you will need. Invalidate allows it to draw, 'whenever it gets around to it', whereas .Refresh will tell it to stop what it is doing and redraw right then. This will work. There is a minor hit in performance from doing this, but it won't matter in your case, because the cost of the redraw will be too small to matter.
My usual boring signature: Nothing
-
Mar 2nd, 2016, 06:22 PM
#4
Thread Starter
New Member
Re: Progress in Listbox step by step.
OK, It works like I want. Thanks a lot Shaggy.
Last edited by Koen A; Mar 2nd, 2016 at 06:27 PM.
Reason: Solved
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|