How can you detect a mouse double click on a text box?

  • Thread starter Thread starter Harry J. Smith
  • Start date Start date
H

Harry J. Smith

How can you detect a mouse double click on a text box? I tried the following
but it does not work.

private void richTextOut_MouseUp(object sender,
System.Windows.Forms.MouseEventArgs e)

// Process Mouse up in output TextBox

{

if (e.Clicks == 1) // if a single click (always == 1 ??)

{

SelectCom();

}

if (e.Clicks == 2) // if a double click (never == 2 ??)

{

SelectCom();

buttonDoIt_Click(sender, e);

}

}

-Harry
 
Harry J. Smith said:
How can you detect a mouse double click on a text box? I tried the following
but it does not work.

private void richTextOut_MouseUp(object sender,
System.Windows.Forms.MouseEventArgs e)

// Process Mouse up in output TextBox

{

if (e.Clicks == 1) // if a single click (always == 1 ??)

{

SelectCom();

}

if (e.Clicks == 2) // if a double click (never == 2 ??)

{

SelectCom();

buttonDoIt_Click(sender, e);

}

}

-Harry

You need to set the window style to accept double click events.
 
Julie said:
Look into ControlStyles.StandardDoubleClick and the Control.DoubleClick
event.

This is the code I have entered. It compiles but the _Click and _DoubleClick
code is never entered:

this.richTextOut.Click += new System.EventHandler(this.richTextOut_Click);
this.richTextOut.Click += new
System.EventHandler(this.richTextOut_DoubleClick


this.SetStyle(ControlStyles.StandardClick |
ControlStyles.StandardDoubleClick,


private void richTextOut_Click(object sender, System.EventArgs e)
{
...
}

private void richTextOut_DoubleClick(object sender, System.EventArgs e)
{
....
}

-Harry
 
I still need help on this.

-Harry

Harry J. Smith said:
event.

This is the code I have entered. It compiles but the _Click and _DoubleClick
code is never entered:

this.richTextOut.Click += new System.EventHandler(this.richTextOut_Click);
this.richTextOut.Click += new
System.EventHandler(this.richTextOut_DoubleClick


this.SetStyle(ControlStyles.StandardClick |
ControlStyles.StandardDoubleClick,


private void richTextOut_Click(object sender, System.EventArgs e)
{
...
}

private void richTextOut_DoubleClick(object sender, System.EventArgs e)
{
....
}

-Harry
 
Back
Top