how to i create a listview with more rows? i cant get it working
Printable View
how to i create a listview with more rows? i cant get it working
vb.net 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
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 ?
sorry i am just started to vb i already have writte code in Autoit but i want vb now.
Do you have any code that is not working? If Yes, you can post it here.
to add more rows use:
Code:ListBoxName.Items.Add(String_to_Add)
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.Quote:
Originally Posted by yucatan
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.
Quote:
Originally Posted by si_the_geek
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
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.
it means either you didn't add a listview to your form, or you did add one, but you didn't name it ListView1Quote:
Originally Posted by yucatan