I am trying to work with listbox in visual stuido 2008. I am new to c# as of 2 days ago however im very experienced with c++ and batch. I was wondering if someone could give me some quick help on how to use mouse clicks.

In particular i have a form with a listbox and its populated with lots of strings. When the user clicks on one of those strings i would like to process data based on that string.

For example:
| str |
| str2 |

Double click str.


Ive been searching for hours and all i seem to know is that
people like to use e as a variable for EventArgs. and that you might have to use
this.MouseDoubleClick += new MouseEventHandler(Something);

im lost lol
any help ?

In design mode select your listbox. Go to the properties window(usually low right). Select events(click on the lightning bolt icon.
Scroll to MouseDoubleClick and fill in a name you like (e.g. MyMouseDblClick) Press enter and see what happens. Continue from there.

Thanks, i didnt know it was that simple :)
After making that function i was able to get the mouse click to do something. And then i came to this conclusion:
If Cfg is the name of my listbox.

public void OnDoubleClick(object sender, MouseEventArgs e)
            string Value="";
            Value = Cfg.Items[Cfg.SelectedIndex].ToString();

With that on click you get the name of what was clicked stored in value. Finally lol.

Thanks ddanbe

This question has already been answered. Start a new discussion instead.