Reputation: 306
As the title said i want to open a new specif window for each item that is clicked in a listview much like a contents page. The code i have so far is...
Private Sub LvLesson_DoubleClick(sender As Object, e As EventArgs) Handles LvLesson.DoubleClick
If LvLesson.FullRowSelect.ToString = "lesson 4" Then
MessageBox.Show("Hello")
End If
End Sub
the messagebox was just a test. I have four items lesson 1, 2, 3, 4 i simply want to click on 1 or 2 etc and open form 1 or 2 etc.
Upvotes: 0
Views: 1886
Reputation: 27322
The documentation is your friend.
FullRowSelect is a Boolean property indicating whether the full row is selected or not when an item is clicked.
you want something like the SelectedItems property. This gives you access to the items of the listview that are currently selected.
For example:
Private Sub ListView1_DoubleClick(sender As Object, e As EventArgs) Handles ListView1.DoubleClick
'Check we actually have something selected
If ListView1.SelectedItems.Count > 0 Then
'find out which items is selected and open the appropriate form
Select Case ListView1.SelectedItems(0).Text
Case "lesson 1"
MessageBox.Show("Open Form 1")
Case "lesson 2"
MessageBox.Show("Open Form 2")
Case "lesson 3"
MessageBox.Show("Open Form 3")
Case "lesson 4"
MessageBox.Show("Open Form 4")
End Select
End If
End Sub
Upvotes: 1