leeds2000
asked on
Don get value from my listview
here is the code im using to drag the value from the listview
Dim vareantall As String = Me.listviewordre.SelectedI tems.(2).T ext
Dim varenummer As String = Me.listviewordre.SelectedI tems(1).Te xt
Below is the code for my listview, why dont i get the values i need??
And yes i have values inside my listview box, they are gathered from a database, but i get error when trying the code above, to get values from column 1 and 2
Dim vareantall As String = Me.listviewordre.SelectedI
Dim varenummer As String = Me.listviewordre.SelectedI
Below is the code for my listview, why dont i get the values i need??
And yes i have values inside my listview box, they are gathered from a database, but i get error when trying the code above, to get values from column 1 and 2
With Me.listviewordre
.GridLines = True
.MultiSelect = False
.FullRowSelect = True
.View = View.Details
.HideSelection = False
.Columns.Add("O. nr", 35, HorizontalAlignment.Center)
.Columns.Add("V. nr", 35, HorizontalAlignment.Center)
.Columns.Add("Ant.", 35, HorizontalAlignment.Center)
.Columns.Add("Salgsdato", 68, HorizontalAlignment.Center)
'.Columns.Add("Kundenr", 45, HorizontalAlignment.Center)
.Columns.Add("Varenavn", 111, HorizontalAlignment.Center)
'.Columns.Add("Varetype", 65, HorizontalAlignment.Center)
.Columns.Add("Pris", 50, HorizontalAlignment.Center)
.Columns.Add("Kundenavn", 100, HorizontalAlignment.Center)
.Columns.Add("Adresse", 185, HorizontalAlignment.Center)
'.Columns.Add("Postnummer", 65, HorizontalAlignment.Center)
'.Columns.Add("Poststed", 65, HorizontalAlignment.Center)
.Columns.Add("Ansatt", 45, HorizontalAlignment.Center)
'.Columns.Add("Fullført", 55, HorizontalAlignment.Center)
End With
Dim lstItem As ListViewItem
While dataleser.Read()
lstItem = New ListViewItem()
lstItem.Text = dataleser.GetInt32(0)
lstItem.SubItems.Add(dataleser.GetInt32(1))
lstItem.SubItems.Add(dataleser.GetInt32(2))
lstItem.SubItems.Add(dataleser.GetOracleDateTime(3))
'lstItem.SubItems.Add(dataleser.GetInt32(4))
lstItem.SubItems.Add(dataleser.GetString(5))
'lstItem.SubItems.Add(dataleser.GetString(6))
lstItem.SubItems.Add(dataleser.GetInt32(7))
lstItem.SubItems.Add(dataleser.GetString(8) & " " & dataleser.GetString(9))
lstItem.SubItems.Add(dataleser.GetString(10) & " " & dataleser.GetString(11) & " " & dataleser.GetString(12))
'lstItem.SubItems.Add(dataleser.GetString(11))
'lstItem.SubItems.Add(dataleser.GetString(12))
lstItem.SubItems.Add(dataleser.GetInt32(13))
'lstItem.SubItems.Add(dataleser.GetString(14))
Me.listviewordre.Items.Add(lstItem)
End While
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SelectedItems returns the list of items that are currently selected, that is, highlighted (just one if MultiSelect is set to False).
But if there is not selected item or there are less items selected than what you are trying to access, then you will cause an Exception.
But if there is not selected item or there are less items selected than what you are trying to access, then you will cause an Exception.
ASKER
is this becouse the others are subitems? how do i get values from subitems?