How to Get Value from Selected Item in Listview
Submitted by admin on Tuesday, April 21, 2009 - 12:06.
I am struggling before on how to get value from selected item in a listview.
As you've seen in my Hotel Reservation System (VB.NET Version) I use the following code to get the value from a Listview.
Although it is working fine but the succeding code will generate an error in the IDE of VB.NET.
After searching the internet I found a good solution to this problem. Just change the code above with this code:
- Dim FolioNumber As String
- For Each sItem As ListViewItem In lvList.SelectedItems
- FolioNumber = sItem.Text
- Next
- With frmCheckIn
- .State = modGlobal.FormState.adStatePopupMode
- .FolioNumber = FolioNumber '< = Variable "FolioNumber" is used before it has been assigned a value. A null reference exception could result at runtime.
- .ShowDialog()
- Call FillList()
- End With
- .FolioNumber = lvList.SelectedItems(0).Text
Add new comment
- 59 views