Results 1 to 10 of 10

Thread: listview

  1. #1

    Thread Starter
    New Member
    Join Date
    Jul 2008
    Posts
    4

    listview

    how to i create a listview with more rows? i cant get it working

  2. #2
    PowerPoster Deepak Sakpal's Avatar
    Join Date
    Mar 2002
    Location
    Mumbai, India
    Posts
    2,424

    Re: listview

    vb.net Code:
    1. Public Class Form2
    2.  
    3.     Private Sub Form2_Load( _
    4.         ByVal sender As System.Object, _
    5.         ByVal e As System.EventArgs _
    6.     ) Handles MyBase.Load
    7.  
    8.         CreateMyListView()
    9.     End Sub
    10.  
    11.     Private Sub CreateMyListView()
    12.         ' Set the view to show details.
    13.         ListView1.View = View.Details
    14.         ' Allow the user to edit item text.
    15.         ListView1.LabelEdit = True
    16.         ' Allow the user to rearrange columns.
    17.         ListView1.AllowColumnReorder = True
    18.         ' Display check boxes.
    19.         ListView1.CheckBoxes = True
    20.         ' Select the item and subitems when selection is made.
    21.         ListView1.FullRowSelect = True
    22.         ' Display grid lines.
    23.         ListView1.GridLines = True
    24.         ' Sort the items in the list in ascending order.
    25.         ListView1.Sorting = SortOrder.Ascending
    26.  
    27.         ' Create three items and three sets of subitems for each item.
    28.         Dim item1 As New ListViewItem("item1", 0)
    29.         ' Place a check mark next to the item.
    30.         item1.Checked = True
    31.         item1.SubItems.Add("1")
    32.         item1.SubItems.Add("2")
    33.         item1.SubItems.Add("3")
    34.         Dim item2 As New ListViewItem("item2", 1)
    35.         item2.SubItems.Add("4")
    36.         item2.SubItems.Add("5")
    37.         item2.SubItems.Add("6")
    38.         Dim item3 As New ListViewItem("item3", 0)
    39.         ' Place a check mark next to the item.
    40.         item3.Checked = True
    41.         item3.SubItems.Add("7")
    42.         item3.SubItems.Add("8")
    43.         item3.SubItems.Add("9")
    44.  
    45.         ' Create columns for the items and subitems.
    46.         ListView1.Columns.Add("Item Column")
    47.         ListView1.Columns.Add("Column 2")
    48.         ListView1.Columns.Add("Column 3")
    49.         ListView1.Columns.Add("Column 4")
    50.  
    51.         'Add the items to the ListView.
    52.         ListView1.Items.AddRange(New ListViewItem() {item1, item2, item3})
    53.     End Sub
    54.  
    55. End Class

  3. #3

    Thread Starter
    New Member
    Join Date
    Jul 2008
    Posts
    4

    Re: listview

    when i select the code copy it and paste it i get all the numbers before the lines how i can copy it without the numbers because else i need to go remove all numbers by hand ?

  4. #4

    Thread Starter
    New Member
    Join Date
    Jul 2008
    Posts
    4

    Re: listview

    sorry i am just started to vb i already have writte code in Autoit but i want vb now.

  5. #5

  6. #6
    Addicted Member sauronsmatrix's Avatar
    Join Date
    Jun 2008
    Location
    USA
    Posts
    133

    Re: listview

    to add more rows use:

    Code:
    ListBoxName.Items.Add(String_to_Add)

  7. #7
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    41,974

    Re: listview

    Quote Originally Posted by yucatan
    when i select the code copy it and paste it i get all the numbers before the lines how i can copy it without the numbers because else i need to go remove all numbers by hand ?
    First of all, I apologise for your question being hidden until now - our spam protection decided it needed to be manually approved. This should not happen for you again.

    To copy code without the numbers there are various ways, I find the easiest is to press the "Quote" button, and when the page loads copy it from there.

  8. #8

    Thread Starter
    New Member
    Join Date
    Jul 2008
    Posts
    4

    Re: listview

    Quote Originally Posted by si_the_geek
    First of all, I apologise for your question being hidden until now - our spam protection decided it needed to be manually approved. This should not happen for you again.

    To copy code without the numbers there are various ways, I find the easiest is to press the "Quote" button, and when the page loads copy it from there.

    when i execute this code

    Public Class Form2

    Private Sub Form2_Load( _
    ByVal sender As System.Object, _
    ByVal e As System.EventArgs _
    ) Handles MyBase.Load

    CreateMyListView()
    End Sub

    Private Sub CreateMyListView()
    ' Set the view to show details.
    ListView1.View = View.Details
    ' Allow the user to edit item text.
    ListView1.LabelEdit = True
    ' Allow the user to rearrange columns.
    ListView1.AllowColumnReorder = True
    ' Display check boxes.
    ListView1.CheckBoxes = True
    ' Select the item and subitems when selection is made.
    ListView1.FullRowSelect = True
    ' Display grid lines.
    ListView1.GridLines = True
    ' Sort the items in the list in ascending order.
    ListView1.Sorting = SortOrder.Ascending

    ' Create three items and three sets of subitems for each item.
    Dim item1 As New ListViewItem("item1", 0)
    ' Place a check mark next to the item.
    item1.Checked = True
    item1.SubItems.Add("1")
    item1.SubItems.Add("2")
    item1.SubItems.Add("3")
    Dim item2 As New ListViewItem("item2", 1)
    item2.SubItems.Add("4")
    item2.SubItems.Add("5")
    item2.SubItems.Add("6")
    Dim item3 As New ListViewItem("item3", 0)
    ' Place a check mark next to the item.
    item3.Checked = True
    item3.SubItems.Add("7")
    item3.SubItems.Add("8")
    item3.SubItems.Add("9")

    ' Create columns for the items and subitems.
    ListView1.Columns.Add("Item Column")
    ListView1.Columns.Add("Column 2")
    ListView1.Columns.Add("Column 3")
    ListView1.Columns.Add("Column 4")

    'Add the items to the ListView.
    ListView1.Items.AddRange(New ListViewItem() {item1, item2, item3})
    End Sub

    End Class

    i get name listview1 is not declared.



    why is that did i do something wrong ? sorry i'm a starter in vb

  9. #9
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    41,974

    Re: listview

    Please do not bump your threads (I have deleted your bump post).

    For some of the reasons, see this. People will read your thread (and hopefully reply) when they get the time to do so.

  10. #10
    I'm about to be a PowerPoster! kleinma's Avatar
    Join Date
    Nov 2001
    Location
    NJ - USA (Near NYC)
    Posts
    23,373

    Re: listview

    Quote Originally Posted by yucatan
    i get name listview1 is not declared.

    why is that did i do something wrong ? sorry i'm a starter in vb
    it means either you didn't add a listview to your form, or you did add one, but you didn't name it ListView1

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