msg所选项目列表框VB.net

时间:2019-04-12 08:42:01

标签: vb.net

我尝试在消息中显示我选择的项目,但它显示为索引而不是项目字符串。

我的代码:

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

1 个答案:

答案 0 :(得分:0)

为什么要尝试将索引位置获取为数字? 试试这个:

    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

希望它是您想要的。