Results 1 to 4 of 4

Thread: Adding Items to LIstviews at Runtime......HELP!

  1. #1
    tgo57
    Guest

    Adding Items to LIstviews at Runtime......HELP!

    I need the ability to add/delete/modify rows to a listview.
    ***********************************
    * name * Ip address* Status * Ping*
    ***********************************
    * Joe * 24.5.123.1* online * 123 *
    * Bill * 24.1.2.3 * online * 234 *
    * etc. *
    ***********************************

    These rows can change at any time depending if someone is connected. I also do not know in advance how many rows there will be.
    Problem: Listviews want you to define the row items (name, joe bill, etc) in the code before you start using them??? How can I do this or should I use a different control such as the GRID Control?......Much appreciate your answers.

  2. #2
    Fanatic Member kinjalgp's Avatar
    Join Date
    Apr 2000
    Location
    India
    Posts
    535
    Use the string array to store name*ip address...... and then
    modify this array and use
    Code:
    List.Clear
    List.Additem Array(index)
    Kinjal

  3. #3
    tgo57
    Guest

    understood.....but

    Yes this would do it........but I then have to keep track of how many connections are added to array and make sure I allocate enough elements in the array, I really don't know how many connections Im going to have so using the array could be risky?
    Is there not a better way? Is this it?

  4. #4
    Fanatic Member kinjalgp's Avatar
    Join Date
    Apr 2000
    Location
    India
    Posts
    535
    VB allows one to redimesion arrays at runtime.

    use following code :
    Code:
    Dim Arr() as string
    
    Private Sub UserAdded()
               Redim Preserve Arr(ubound(arr)+1)
               Arr(ubound(arr))="Details of new user"
               Call WriteToList
    End Sub
    
    Private Sub WriteToList
             List1.Clear
             Dim i as integer
             For i=0 to ubound(arr)
                     List1.Additem arr(i)
             Next  
    
    End Sub
    Hope this will solve your problem. This code will take any number of user until you have RAM left on your system.

    Kinjal

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