This is a migrated thread and some comments may be shown as answers.

RadTextBox click and double click events

6 Answers 537 Views
TextBox
This is a migrated thread and some comments may be shown as answers.
Max
Top achievements
Rank 1
Max asked on 11 May 2008, 03:00 PM
Hi!
In new version these events works only if you click on the border of the textbox, how can I catch event when user click on "work" space of textbox ?

6 Answers, 1 is accepted

Sort by
0
Martin Vasilev
Telerik team
answered on 12 May 2008, 01:28 PM
Hi Max,

Thank you for the question.

You could handle the Click and DoubleClick events in TexBoxItem by using the code provided below:

private void Form1_Load(object sender, EventArgs e)  
{  
    this.radTextBox1.TextBoxElement.TextBoxItem.Click += new EventHandler(TextBoxItem_Click);  
    this.radTextBox1.TextBoxElement.TextBoxItem.DoubleClick += new EventHandler(TextBoxItem_DoubleClick);  
}  
 
void TextBoxItem_DoubleClick(object sender, EventArgs e)  
{  
    //do something...  
}  
 
void TextBoxItem_Click(object sender, EventArgs e)  
{  
    //do something...  

I hope this helps. If you need additional assistance, do not hesitate to contact me again.

Sincerely yours,
Martin Vasilev
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
Martin Lundgard
Top achievements
Rank 2
answered on 07 May 2010, 09:25 AM

This workaround makes me go into every load page code and wire the events, this is alot of work when I'm just upgrading a project that already has 1000's of event handlers.

How can you make the RadTextBox.TextBoxElement.TextBoxItem.Click event call the RadTextBox.Click event?
I was thinking inheriting the RadTextBox and rethrow the event from the textboxitem...
Other suggestions / code is appreciated.

0
Martin Vasilev
Telerik team
answered on 13 May 2010, 08:35 AM
Hello Arve Asheim,

Thank you for getting back to me.

Actually, you can override RadTextBox control and link its Click event to the TextBoxItem's Click event. Please, consider the following code:
class CustomTextBox : RadTextBox
    {
        public CustomTextBox()
        {
            this.TextBoxElement.TextBoxItem.Click += new EventHandler(TextBoxItem_Click);
            this.TextBoxElement.TextBoxItem.DoubleClick += new EventHandler(TextBoxItem_DoubleClick);
        }
  
        void TextBoxItem_DoubleClick(object sender, EventArgs e)
        {
            base.OnDoubleClick(e);
        }
  
        void TextBoxItem_Click(object sender, EventArgs e)
        {
            base.OnClick(e);
        }
  
        public override string ThemeClassName
        {
            get
            {
                return typeof(RadTextBox).FullName;
            }
        }   
    }

Let me know if you have any other questions.

Greetings,
Martin Vasilev
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
Dave Galligher
Top achievements
Rank 2
answered on 18 Oct 2011, 09:03 PM
Hi Martin,

I don't want to hijack the thread, but can you tell me how then if we are using the EventArgs instead of MouseEventArgs can we tell which button (left button or right button) the user double-clicked with - in my case there needs to be a difference. Also, based on the example given seems like Click is always occurring no matter how fast I double-click.

Thank you.

Dave Galligher
0
Dave Galligher
Top achievements
Rank 2
answered on 18 Oct 2011, 09:26 PM
I figured out the issue with the button - right or left, you need to convert the EventArg to a MouseEventArg and then read what button was clicked. Original click issue still stands when both events are defined.

0
Martin Vasilev
Telerik team
answered on 21 Oct 2011, 03:58 PM
Hi Dave,

I am glad you have a found solution for your scenario. Do not hesitate to contact us if you have any other questions.

All the best,
Martin Vasilev
the Telerik team

Q2’11 SP1 of RadControls for WinForms is available for download (see what's new); also available is the Q3'11 Roadmap for Telerik Windows Forms controls.

Tags
TextBox
Asked by
Max
Top achievements
Rank 1
Answers by
Martin Vasilev
Telerik team
Martin Lundgard
Top achievements
Rank 2
Dave Galligher
Top achievements
Rank 2
Share this question
or