|
-
Aug 25th, 2003, 03:18 PM
#1
Thread Starter
Hyperactive Member
ListView Question
I'm confused with .Net's version of the ListView box..
In VB6, If I wanted to make sure a element in the list was actually selected before working with it, i would just do a..
If lstbox.SelectedIndex > -1 Then
....Do Code...
End If
How do I make sure an element in a listview in .Net is selected? If the user doesn't select an item, then it throws an error when I try to retrieve the ListViewItem like so..
Dim lv As ListViewItem = lstChar.SelectedItems(0)
I don't even know if this is the correct way to get the selected item from the list. Is there another way to get the text from the selected item in the list?
-
Aug 25th, 2003, 04:03 PM
#2
You can check if anything is selected first:
VB Code:
If lstChar.SelectedItems.Length>0
Dim lv As ListViewItem = lstChar.SelectedItems(0)
End if
'or
If Not lstChar.SelectedItems.Length Is Nothing
Dim lv As ListViewItem = lstChar.SelectedItems(0)
End if
-
Aug 25th, 2003, 04:10 PM
#3
Thread Starter
Hyperactive Member
Thank you Edneeis, Had to change the .Length to .Count but it works great...
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|