C# Listbox Item Double Click Event

后端 未结 6 762
天命终不由人
天命终不由人 2020-12-08 06:00

I have a list box with some items. Is there anyway I can attach a double click event to each item?

Item 1
Item 2
Item 3

If i was to double

6条回答
  •  孤城傲影
    2020-12-08 06:47

    void listBox1_MouseDoubleClick(object sender, MouseEventArgs e)
        {
             int index = this.listBox1.IndexFromPoint(e.Location);
             if (index != System.Windows.Forms.ListBox.NoMatches)
                {
                  MessageBox.Show(index.ToString());
                }
         }
    

    This should work...check

提交回复
热议问题