Confused ListView Right Click
Hey i have been working ON a mailing app for a company that is all SQL based i have most of it working but theres one thing that has me confused
it errors out if you right click and theres no name selected
vb Code:
Private Sub ListView2_MouseClick(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles ListView2.MouseClick
If e.Button = Windows.Forms.MouseButtons.Right Then
Dim myListView As ListView 'Assign your ListView here.
myListView = ListView2
For itemIndex As Integer = 0 To myListView.SelectedItems.Count - 1
For subitemIndex As Integer = 1 To myListView.Columns.Count - 1
If myListView.SelectedItems(itemIndex).Text = "" Then
MsgBox(" You Need To Select A UserName")
ContextMenuStrip3.Close()
Else
ContextMenuStrip3.Show()
USERNAMEToolStripMenuItem.Text = myListView.SelectedItems(itemIndex).Text
End If
Next
Next
End If
End Sub
i have tryed that code in the contect menu opening sub and also int he click sub but both dont work can anyone help me figure out ware i have gone Wrong
Re: Confused ListView Right Click
so at line 8 you're expecting the code to enter into the error message code block if they right click on no name? Have you set a break point at this line and tested to see what value myListView.SelectedItems(itemIndex).Text contains when you perform this action?
Re: Confused ListView Right Click
ok i tryed that i added a msgbox that should popup and display the value of the item
BUT wheni right click on the control nothing happens
so is there something wrong with my right click code or something
Re: Confused ListView Right Click
ok so i done some looking and its my right click that isnt working right soo im at a loss