Results 1 to 4 of 4

Thread: Progress in Listbox step by step.

  1. #1

    Thread Starter
    New Member
    Join Date
    Jul 2012
    Posts
    5

    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

  2. #2
    Smooth Moperator techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,532

    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
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  3. #3
    Super Moderator Shaggy Hiker's Avatar
    Join Date
    Aug 2002
    Location
    Idaho
    Posts
    38,988

    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

  4. #4

    Thread Starter
    New Member
    Join Date
    Jul 2012
    Posts
    5

    Resolved 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
  •  



Click Here to Expand Forum to Full Width