| | |
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 barchart bitmap box broadcast buttons c# chat check checkbox client color combobox control conversion csharp custom database datagrid datagridview dataset datetime degrees development draganddrop drawing enabled encryption enum event excel file files form format forms function gdi+ httpwebrequest image index input install java label list listbox listener load mandelbrot math mouseclick mysql networking operator path photoshop picturebox pixelinversion post prime programming radians regex remote remoting resolved. richtextbox save saving serialization server sleep socket sql statistics stream string table tcp text textbox thread time timer treeview update usercontrol validation view visualstudio webbrowser windows winforms wpf xml






