Click here to Skip to main content
15,921,548 members
Home / Discussions / C#
   

C#

 
QuestionRegasm Registration Problem Pin
swamy Narasimha28-Aug-07 21:07
swamy Narasimha28-Aug-07 21:07 
QuestionParsing Text file Data Pin
MussaratAziz28-Aug-07 20:32
MussaratAziz28-Aug-07 20:32 
AnswerRe: Parsing Text file Data Pin
Christian Graus28-Aug-07 20:45
protectorChristian Graus28-Aug-07 20:45 
AnswerRe: Parsing Text file Data Pin
J4amieC28-Aug-07 22:11
J4amieC28-Aug-07 22:11 
GeneralRe: Parsing Text file Data Pin
ChandraRam28-Aug-07 23:50
ChandraRam28-Aug-07 23:50 
GeneralRe: Parsing Text file Data Pin
J4amieC29-Aug-07 0:32
J4amieC29-Aug-07 0:32 
Questiondouble click on ListBox items Pin
Maddie from Dartford28-Aug-07 20:25
Maddie from Dartford28-Aug-07 20:25 
AnswerRe: double click on ListBox items Pin
Martin#28-Aug-07 21:33
Martin#28-Aug-07 21:33 
Hello,

Interesting question!

I have a very dirty workaround for you. Some, might say I only provide dirty solutions Wink | ;)

.)
Easy solution would be to use the MouseDown event and chack the Clicks property of the MouseEventArgs.
I know that "Clicks>1" is not equal doubleclick, but maybe it fits for you.
Here you can do a check if the Y position of the MouseEventArgs is inside a region.
This region can be validated with the "PreferredHeight" property of the ArrayList class.
Dirty is, that it needs an offset depending on the "BoarderStyle" you are using.
Here an example:
private void yourListBoxes_MouseDown(object sender, System.Windows.Forms.MouseEventArgs e)
{
	//Not really DoubleClick, but maybe ok for you
	if(e.Clicks>1)
	{
		ListBox ActListBox = sender as ListBox;
		int YactHeight;
		if(ActListBox.BorderStyle == BorderStyle.None)
		{
			YactHeight= ActListBox.PreferredHeight;
		}
		else
		{
			YactHeight= ActListBox.PreferredHeight - 8;	//Offset needed
		}
		if(e.Y<=YactHeight)
		{
                        //Is inside Items region
                        //Do stuff here
                }
	}
}

If you need it more often I would suggest you to inherit your ownb ListBox.
This should override the OnMouseDown method and do the validation there.
If the position is inside the Items region you could fire an custom event there, which you handle in your code.

.)
The other solution could be, to handle the DoubleClick.
As the System.EventArgs do not provide a act position, you would have to use the Cursor position in combination with the controls position PointToScreen.

Hope it helps!

All the best,

Martin

GeneralRe: double click on ListBox items Pin
Maddie from Dartford29-Aug-07 2:04
Maddie from Dartford29-Aug-07 2:04 
GeneralRe: double click on ListBox items Pin
Martin#29-Aug-07 2:11
Martin#29-Aug-07 2:11 
Questionreports in c# Pin
Sonia Gupta28-Aug-07 20:13
Sonia Gupta28-Aug-07 20:13 
QuestionRendering movie in Desktop background Pin
Anindya Chatterjee28-Aug-07 19:54
Anindya Chatterjee28-Aug-07 19:54 
QuestionWord file parser Pin
Rahul.RK28-Aug-07 19:13
Rahul.RK28-Aug-07 19:13 
AnswerRe: Word file parser Pin
Justin Perez29-Aug-07 1:43
Justin Perez29-Aug-07 1:43 
QuestionCalling BRE rules in C# project Pin
Prashant C28-Aug-07 19:13
Prashant C28-Aug-07 19:13 
AnswerRe: Calling BRE rules in C# project Pin
Michael Sync28-Aug-07 19:46
Michael Sync28-Aug-07 19:46 
GeneralRe: Calling BRE rules in C# project Pin
J4amieC28-Aug-07 22:07
J4amieC28-Aug-07 22:07 
GeneralRe: Calling BRE rules in C# project Pin
Michael Sync28-Aug-07 23:18
Michael Sync28-Aug-07 23:18 
QuestionMotion Detection Pin
Hussain Deen28-Aug-07 18:25
Hussain Deen28-Aug-07 18:25 
AnswerRe: Motion Detection Pin
Christian Graus28-Aug-07 20:47
protectorChristian Graus28-Aug-07 20:47 
QuestionImporting multiple projects (not solutions) in vs2005 at once Pin
shatterstar645728-Aug-07 17:22
shatterstar645728-Aug-07 17:22 
QuestionShared variable across processes Pin
xavierakx28-Aug-07 16:03
xavierakx28-Aug-07 16:03 
AnswerRe: Shared variable across processes Pin
Super Lloyd28-Aug-07 16:50
Super Lloyd28-Aug-07 16:50 
QuestionUPnP C# application&#8207; Pin
crazy friend28-Aug-07 15:23
crazy friend28-Aug-07 15:23 
AnswerRe: xcopy and timestamp Pin
Spacix One28-Aug-07 14:28
Spacix One28-Aug-07 14:28 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.