| | |
Mouse Event Handling Help?
Please support our C# advertiser: Intel Parallel Studio Home
Thread Solved |
•
•
Join Date: Apr 2008
Posts: 27
Reputation:
Solved Threads: 1
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.
MessageBox.Show(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 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.
MessageBox.Show(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.
Scroll to MouseDoubleClick and fill in a name you like (e.g. MyMouseDblClick) Press enter and see what happens. Continue from there.
Last edited by ddanbe; May 14th, 2009 at 6:56 am.
Today is a gift, that's why it is called "The Present".
Make love, no war. Cave ab homine unius libri.
Danny
Make love, no war. Cave ab homine unius libri.
Danny
•
•
Join Date: Apr 2008
Posts: 27
Reputation:
Solved Threads: 1
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.
With that on click you get the name of what was clicked stored in value. Finally lol.
Thanks ddanbe

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.
C# Syntax (Toggle Plain Text)
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
Last edited by DevC++4.9.9.2; May 14th, 2009 at 4:47 pm.
![]() |
Similar Threads
- Dynamic Server Control event handling (ASP.NET)
- help for awt event handling consume fundamantal (Java)
- JSpinner mouse event (Java)
- A doubt in SWING event handling (Java)
- event handling (Visual Basic 4 / 5 / 6)
- Event Handling Help needed please. (Java)
- Java awt and swing event handling (Java)
Other Threads in the C# Forum
- Previous Thread: Playing SWF without flash-player installed
- Next Thread: Office Word
| Thread Tools | Search this Thread |
.net access ado.net algorithm array backup barchart bitmap box broadcast buttons c# check checkbox client combobox control conversion csharp custom database databasesearch datagrid datagridview datagridviewcheckbox dataset datetime degrees development draganddrop drawing dynamiccreation encryption enum equation event excel file form format formatting forms function gdi+ httpwebrequest image index input install interface java label list listbox mandelbrot math mouse mouseclick mysql namevaluepairs operator path photoshop picturebox pixelinversion post powerpacks programming property radians regex remote remoting resource restore richtextbox server sleep socket sql statistics stream string table text textbox thread time timer update usercontrol validation visualstudio wait webbrowser windows winforms working wpf xml






