Results 1 to 5 of 5

Thread: VB - Add a progress bar as a listview item

Threaded View

  1. #1

    Thread Starter
    Fanatic Member Armbruster's Avatar
    Join Date
    Sep 2002
    Location
    Maryland Heights, MO
    Posts
    857

    VB - Add a progress bar as a listview item

    I have seen this asked before, but never answered. This will add a progress bar as a listview item. (See image in attachment)

    VB Code:
    1. Option Explicit
    2.  
    3. Dim itmX As ListItem
    4. Dim i As Integer
    5. Dim j As Integer
    6.  
    7. Private Declare Function SetParent _
    8.        Lib "user32" _
    9.        (ByVal hWndChild As Long, _
    10.        ByVal hWndNewParent As Long) As Long
    11.  
    12. Private Sub Form_Load()
    13.     pbrStatus.Max = 4000
    14.     pbrStatus.Value = 0
    15.     pbrStatus.Visible = False
    16.     SetParent pbrStatus.hWnd, lvwExample.hWnd
    17. End Sub
    18. Private Sub cmdGo_Click()
    19.     pbrStatus.Visible = True
    20.     lvwExample.ListItems.Clear
    21.     For j = 1 To 10
    22.         pbrStatus.Value = 0
    23.         Set itmX = lvwExample.ListItems.Add
    24.         itmX.Text = "Downloading File " & Format(j, "00000")
    25.         lvwExample.ListItems.Item(lvwExample.ListItems.Count).Selected = True
    26.         lvwExample.SelectedItem.EnsureVisible
    27.         itmX.SubItems(1) = "Completed"
    28.         With pbrStatus
    29.             .Move itmX.Left + lvwExample.ColumnHeaders(1).Width, itmX.Top, itmX.Width, itmX.Height
    30.             .Width = lvwExample.ColumnHeaders(2).Width
    31.             .Height = itmX.Height
    32.         End With
    33.         For i = 1 To 4000
    34.             pbrStatus.Value = i
    35.             DoEvents
    36.         Next i
    37.     Next j
    38.     pbrStatus.Visible = False
    39.     pbrStatus.Value = 0
    40. End Sub
    41. Private Sub cmdExit_Click()
    42.     Unload Me
    43. End Sub
    Attached Files Attached Files
    Last edited by Armbruster; Mar 21st, 2003 at 03:05 PM.
    "Look! Up in the sky! It's a bird! It's a plane! It's Diaper-Head Boy! (there by my name!) Yes, Diaper-Head Boy, who disguised as my son, Seth, fights a never-ending battle for truth, justice and terrorizing my house!

    Resistance is futile, you will be compiled . . . Please!

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