Thread View: borland.public.csharpbuilder.winforms.controls.using
6 messages
6 total messages
Started by John Fowler
Thu, 10 Mar 2005 06:40
'Trapping' a double-click in RichTextEdit Mouse-down event
Author: John Fowler
Date: Thu, 10 Mar 2005 06:40
Date: Thu, 10 Mar 2005 06:40
20 lines
1503 bytes
1503 bytes
Hi!
I have a rich text editbox on a form and when I double-click it, I want its text to be copied to myString. However, the program alwaly 'freezes' after the FIRST click; thus e.Clicks == 1 is always true and I can never click fast enough for e.Clicks ever to be '2'.
Here's my code:
private void rtBox_MouseDown(object sender, system.Windows.Forms.MouseEventArgs e)
{
if ( e.Clicks == 2 ) //on double-click, copy text to grid
{
string myString = rtBox.Text;
}
}
How do I 'trap' a double-click so that e.Clicks == 2?
Thank you!
John Fowler.
Re: 'Trapping' a double-click in RichTextEdit Mouse-down event
Author: Marc Rohloff TeamB
Date: Fri, 11 Mar 2005 01:29
Date: Fri, 11 Mar 2005 01:29
19 lines
1834 bytes
1834 bytes
On 9 Mar 2005 22:40:24 -0800, John Fowler wrote: > I have a rich text editbox on a form and when I double-click it, I > want its text to be copied to myString. However, the program alwaly > 'freezes' after the FIRST click; thus e.Clicks == 1 is always true > and I can never click fast enough for e.Clicks ever to be '2'. > private void rtBox_MouseDown(object sender, > system.Windows.Forms.MouseEventArgs e) Why don't you use the double click event? You can't get at it in the designer but it is easy enough to set in code: this.richTextBox1.DoubleClick += new System.EventHandler(this.textBox1_DoubleClick); -- Marc Rohloff [TeamB] marc rohloff -at- myrealbox -dot- com
Re: 'Trapping' a double-click in RichTextEdit Mouse-down event
Author: John
Date: Fri, 11 Mar 2005 03:03
Date: Fri, 11 Mar 2005 03:03
26 lines
1703 bytes
1703 bytes
Thanks very much for the advice, Marc. I'll give it a try! John F. "Marc Rohloff [TeamB]" <"on request"> wrote: >On 9 Mar 2005 22:40:24 -0800, John Fowler wrote: > >> I have a rich text editbox on a form and when I double-click it, I >> want its text to be copied to myString. However, the program alwaly >> 'freezes' after the FIRST click; thus e.Clicks == 1 is always true >> and I can never click fast enough for e.Clicks ever to be '2'. > >> private void rtBox_MouseDown(object sender, >> system.Windows.Forms.MouseEventArgs e) > >Why don't you use the double click event? You can't get at it in the >designer but it is easy enough to set in code: > >this.richTextBox1.DoubleClick += new >System.EventHandler(this.textBox1_DoubleClick); > >-- >Marc Rohloff [TeamB] >marc rohloff -at- myrealbox -dot- com
Re: 'Trapping' a double-click in RichTextEdit Mouse-down event
Author: John Fowler
Date: Fri, 11 Mar 2005 04:13
Date: Fri, 11 Mar 2005 04:13
41 lines
2182 bytes
2182 bytes
Hi, Marc:
I've tried this, but when I double-click within the rich text edit (called 'rtBox' in my code) it does nothing (except the default behaviour, i.e. it high-lights the text in the editbox):
Declaration:
this.rtBox.DoubleClick += new System.EventHandler(this.rtBox_DoubleClick);
private void rtBox_DoubleClick(object sender, System.EventArgs e)
{
string [] text_to_insert = { rtBox.Text };
}
What am I missing?
Thanks, again, for your help! it's much appreciated....
John F.
"Marc Rohloff [TeamB]" <"on request"> wrote:
>On 9 Mar 2005 22:40:24 -0800, John Fowler wrote:
>
>> I have a rich text editbox on a form and when I double-click it, I
>> want its text to be copied to myString. However, the program alwaly
>> 'freezes' after the FIRST click; thus e.Clicks == 1 is always true
>> and I can never click fast enough for e.Clicks ever to be '2'.
>
>> private void rtBox_MouseDown(object sender,
>> system.Windows.Forms.MouseEventArgs e)
>
>Why don't you use the double click event? You can't get at it in the
>designer but it is easy enough to set in code:
>
>this.richTextBox1.DoubleClick += new
>System.EventHandler(this.textBox1_DoubleClick);
>
>--
>Marc Rohloff [TeamB]
>marc rohloff -at- myrealbox -dot- com
Re: 'Trapping' a double-click in RichTextEdit Mouse-down event
Author: Marc Rohloff TeamB
Date: Fri, 11 Mar 2005 22:31
Date: Fri, 11 Mar 2005 22:31
20 lines
1846 bytes
1846 bytes
On 10 Mar 2005 20:13:49 -0800, John Fowler wrote:
> I've tried this, but when I double-click within the rich text edit
> (called 'rtBox' in my code) it does nothing (except the default
> behaviour, i.e. it high-lights the text in the editbox):
Yes you are right it seems to disappear. However I tried your original
code:
private void richTextBox1_MouseDown(object sender,
System.Windows.Forms.MouseEventArgs e)
{
if (e.Clicks==2) MessageBox.Show("c");
}
And it works fine for me.
--
Marc Rohloff [TeamB]
marc rohloff -at- myrealbox -dot- com
Re: 'Trapping' a double-click in RichTextEdit Mouse-down event
Author: John
Date: Sun, 13 Mar 2005 19:28
Date: Sun, 13 Mar 2005 19:28
26 lines
1759 bytes
1759 bytes
Thanks, Marc: I'll give it another try.
John F.
"Marc Rohloff [TeamB]" <"on request"> wrote:
>On 10 Mar 2005 20:13:49 -0800, John Fowler wrote:
>
>> I've tried this, but when I double-click within the rich text edit
>> (called 'rtBox' in my code) it does nothing (except the default
>> behaviour, i.e. it high-lights the text in the editbox):
>
>Yes you are right it seems to disappear. However I tried your original
>code:
>
>private void richTextBox1_MouseDown(object sender,
>System.Windows.Forms.MouseEventArgs e)
>{
>if (e.Clicks==2) MessageBox.Show("c");
>}
>
>And it works fine for me.
>
>--
>Marc Rohloff [TeamB]
>marc rohloff -at- myrealbox -dot- com
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads