我尝试在消息中显示我选择的项目,但它显示为索引而不是项目字符串。
我的代码:
Private Sub listBox1_MouseDoubleClick(ByVal sender As Object, ByVal e As MouseEventArgs)
Dim index As Integer = Me.listBox1.IndexFromPoint(e.Location)
If index <> System.Windows.Forms.ListBox.NoMatches Then
MessageBox.Show(index.ToString())
End If
End Sub
为什么你试图将索引位置作为数字?!试试这个 :
Private Sub listBox1_MouseDoubleClick(ByVal sender As Object, ByVal e As MouseEventArgs)
Dim valuee As String = Me.ListBox1.SelectedItem
MessageBox.Show(valuee.ToString())
End Sub
希望它能满足您的需求。