Results 1 to 4 of 4

Thread: how do i ad data to my listview control

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Sep 2000
    Posts
    103

    Talking

    here is my code how do i add data to these columnsplease help me!!

    Code:
    Private Sub Form_Load()
    
    'creat obj var for columnHeader obj and listitem obj
    Dim sColumn As ColumnHeader
    Dim sitem As ListItem
    
    
    'start in report view
    listview1.View = lvwReport
    
    'set the size and pos of the listview
    
    listview1.Width = ScaleWidth
    listview1.Height = ScaleHeight
    listview1.Top = ScaleTop
    listview1.Left = ScaleLeft
    
    'add columnHeaders..the width of the columns is
    'the widht of the ctrl / 2 by the num of headers
    
    Set sColumn = listview1.ColumnHeaders.Add(, , "Name")
    Set sColumn = listview1.ColumnHeaders.Add(, , "Phone #1")
    Set sColumn = listview1.ColumnHeaders.Add(, , "Phone #2")
    
    
    
    
    
    End Sub

  2. #2
    Big D Danial's Avatar
    Join Date
    Jul 2000
    Location
    ASP.Net Forum
    Posts
    2,877
    Try this,

    Code:
    Private Sub Form_Load()
    
    'creat obj var for columnHeader obj and listitem obj
    Dim sColumn As ColumnHeader
    Dim sitem As ListItem
    
    
    'start in report view
    ListView1.View = lvwReport
    
    'set the size and pos of the listview
    
    ListView1.Width = ScaleWidth
    ListView1.Height = ScaleHeight
    ListView1.Top = ScaleTop
    ListView1.Left = ScaleLeft
    
    'add columnHeaders..the width of the columns is
    'the widht of the ctrl / 2 by the num of headers
    
    Set sColumn = ListView1.ColumnHeaders.Add(, , "Name")
    Set sColumn = ListView1.ColumnHeaders.Add(, , "Phone #1")
    Set sColumn = ListView1.ColumnHeaders.Add(, , "Phone #2")
    
    For i = 1 To 10
        ListView1.ListItems.Add , , i
        ListView1.ListItems(i).SubItems(1) = Format(Str(Int(Rnd * 100000000)), "0-###-###-####")
        ListView1.ListItems(i).SubItems(2) = Format(Str(Int(Rnd * 100000000)), "0-###-###-####")
    Next i
    
    
    End Sub
    [VBF RSS Feed]

    There is a great war coming. Are you sure you are on the right side? Atleast I have chosen a side.

    If I have been helpful, Please Rate my Post. Thanks.

    This post was powered by :

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Sep 2000
    Posts
    103

    thanks alot that worked

    but if i want to edit that data displayed how would i do that????

  4. #4
    Big D Danial's Avatar
    Join Date
    Jul 2000
    Location
    ASP.Net Forum
    Posts
    2,877
    Here is how u can edit the Data at Runtime. Or You can click on the item twice(not Double Click) to edit it.

    Code:
    Private Sub Command1_Click()
    ListView1.SelectedItem.Text = "New Name"
    ListView1.SelectedItem.ListSubItems(1) = "New Phone No1"
    ListView1.SelectedItem.ListSubItems(2) = "New Phone No2"
    End Sub
    [VBF RSS Feed]

    There is a great war coming. Are you sure you are on the right side? Atleast I have chosen a side.

    If I have been helpful, Please Rate my Post. Thanks.

    This post was powered by :

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