Hi, im trying to make a listbox Selects it items when the users doubleclicks over the item, but so far i cant get it done, can someone tell me how to do this ??
thanks
:)
Printable View
Hi, im trying to make a listbox Selects it items when the users doubleclicks over the item, but so far i cant get it done, can someone tell me how to do this ??
thanks
:)
I hope i don't misunderstand your question, but is it that you're displaying items in a listbox and when the user clicks on an item, select and display the item that was selected? If so then:
Let's say we have a listbox named lst1
Jennifer.Code:// add some items to listbox lst1
lst1.Items.Add("monday");
lst1.Items.Add("tuesday");
lst1.Items.Add("wednesday");
lst1.Items.Add("friday");
The event handler behind the list box:
private void lst1_SelectedIndexChanged(object sender, EventArgs e)
{
MessageBox.Show(lst1.SelectedItem.ToString());
}
I want that to happend when the user double clicks the Item,
CSharp Code:
private void ListBox1_MouseDoubleClick(object sender, MouseEventArgs e) { if(this.ListBox1.IndexFromPoint(e.Location) != ListBox.NoMatches) { MessageBox.Show(this.ListBox1.GetItemText(this.ListBox1.SelectedItem)); } }