1 Private Sub lstShowRunning_MouseDoubleClick(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles lstShowRunning.MouseDoubleClick 2 Try 3 If lstShowRunning.SelectedItems.Count > 0 Then 4 If lstShowRunning.SelectedItems(0).ToolTipText <> "" Then 5 Using frmMsg As New frmMessage(lstShowRunning.SelectedItems(0).ToolTipText) 6 frmMsg.ShowDialog() 7 End Using 8 End If 9 10 End If 11 Catch 12 Try 13 If lstShowRunning.SelectedItems.Count > 0 Then 14 MessageBox.Show(lstShowRunning.SelectedItems(0).ToolTipText) 15 End If 16 Catch 17 End Try 18 End Try 19 End Sub 20 End Class
private void listView1_DoubleClick(object sender, EventArgs e)
{
if (listView1.SelectedItems.Count == 0) return;
MessageBox.Show("您單擊的是" + listView1.SelectedItems[0].Text);
}
沒有ListView,是不是 List Control控件?
雙擊會產生NM_DBCLICK消息。
可以在菜單中選擇“視圖”(View)->ClassWizard,在彈出的類管理界面,Class Name選擇你的List Control所在的類名,然後在Object IDs選擇List Control的ID,在右邊的Messages中選擇NM_DBCLICK消息添加即可。