Results 1 to 6 of 6

Thread: How does ListView work? Please help

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Dec 1999
    Posts
    321

    Post

    I don't know how to add items to a listview, I probably don't know anything about it and I can't find anything inte the help other than what commands there are (but not how to use them with ListView). Please, If you know any place where I can find some information about how using a listview, tell me...

    The "vital" things I need to know is how to clear the list and how to add to it.. (and it's columns)....

    Thanks :

  2. #2
    Frenzied Member Mark Sreeves's Avatar
    Join Date
    Nov 1999
    Location
    UK
    Posts
    1,845

    Post

    Right, here goes!

    You can add columns either through the property pages or in code

    Code:
    Private Sub Form_Load()
    	
    ' Add ColumnHeaders. The width of the columns is 
    	' the width of the control divided by the number of 
    	' ColumnHeader objects.
    	ListView1.ColumnHeaders. _
    	Add , , "col1", ListView1.Width / 3
    	ListView1.ColumnHeaders. _
    	Add , , "col2", ListView1.Width / 3, _
    	lvwColumnCenter
    	ListView1.ColumnHeaders. _
    	Add , , "col3", ListView1.Width / 3
    	' Set View property to Report.
    	ListView1.View = lvwReport 
    End Sub
    to add data to rows you have to add a list item.

    data in subsequent columns are sub items of the list item:
    Code:
    Private Sub Command1_Click()
    Dim itmx As ListItem
    
    Set itmx = ListView1.ListItems.Add(, , "somthing in col1")
        ' SubItem 1 to it.
        
          itmx.SubItems(1) = "something in col2"
      
    
        
        ' SubItem 2 to it.
       
          itmx.SubItems(2) = "somethinmg in col3"
    
        
    End Sub
    hope this helps

    ------------------
    Mark Sreeves
    Analyst Programmer

    [email protected]
    A BMW Group Company


    [This message has been edited by Mark Sreeves (edited 01-27-2000).]

  3. #3
    Frenzied Member Mark Sreeves's Avatar
    Join Date
    Nov 1999
    Location
    UK
    Posts
    1,845

    Post

    oh I forgot, to clear the list:

    Code:
    Private Sub Command2_Click()
    ListView1.ListItems.Clear
    End Sub
    ------------------
    Mark Sreeves
    Analyst Programmer

    [email protected]
    A BMW Group Company

  4. #4

    Thread Starter
    Hyperactive Member
    Join Date
    Dec 1999
    Posts
    321

    Post

    Thank you Mark!

    Just another q... how do you make that "code" style where you put code?

  5. #5
    Lively Member
    Join Date
    May 1999
    Posts
    100

    Post

    I can't wite the code because it thinks I will put some code in the message but the info is avaible if you lock at the left field and read the "*UBB Code is ON". There is all commands that you can use..

    ------------------
    Best Regards rancor
    [email protected] http://www.sajberhem.nu


    [This message has been edited by rancor (edited 01-27-2000).]

    [This message has been edited by rancor (edited 01-27-2000).]

  6. #6
    Frenzied Member Mark Sreeves's Avatar
    Join Date
    Nov 1999
    Location
    UK
    Posts
    1,845

    Post

    take a look at http://www.vb-world.net/ubb/ubbcode.html


    ------------------
    Mark Sreeves
    Analyst Programmer

    [email protected]
    A BMW Group Company



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