RadTextBox click and double click events

7 posts, 0 answers
  1. Max
    Max avatar
    6 posts
    Member since:
    Jan 2008

    Posted 11 May 2008 Link to this post

    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 ?
  2. Martin Vasilev
    Admin
    Martin Vasilev avatar
    1061 posts

    Posted 12 May 2008 Link to this post

    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
  3. UI for WinForms is Visual Studio 2017 Ready
  4. Arve Asheim
    Arve Asheim avatar
    8 posts
    Member since:
    Jun 2009

    Posted 07 May 2010 Link to this post

    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.

  5. Martin Vasilev
    Admin
    Martin Vasilev avatar
    1061 posts

    Posted 13 May 2010 Link to this post

    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.
  6. Dave Galligher
    Dave Galligher avatar
    37 posts
    Member since:
    May 2010

    Posted 18 Oct 2011 Link to this post

    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
  7. Dave Galligher
    Dave Galligher avatar
    37 posts
    Member since:
    May 2010

    Posted 18 Oct 2011 Link to this post

    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.

  8. Martin Vasilev
    Admin
    Martin Vasilev avatar
    1061 posts

    Posted 21 Oct 2011 Link to this post

    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.

Back to Top
UI for WinForms is Visual Studio 2017 Ready