Get RadTextBox from RadTextBoxItem

3 posts, 1 answers
  1. Marcus
    Marcus avatar
    17 posts
    Member since:
    Aug 2012

    Posted 16 Mar 2012 Link to this post

    This must be simple, but I have trouble to get this solved ...

    I have a mouse click event proc of which the sender type is a RadTextBoxItem. I need to know the textbox, so type TextBox or RadTextBox. How can this be done?

  2. Answer
    Ivan Petrov
    Admin
    Ivan Petrov avatar
    701 posts

    Posted 19 Mar 2012 Link to this post

    Hi Marc,

    Thank you for writing.

    If I understand you correct, you want to get the RadTextBox control from the event handler of the RadTextBoxItem Click event. If this is the case here is a code snippet which demonstrates how to achieve this:
    private void TextBoxItem_Click(object sender, EventArgs e)
    {
        RadTextBoxItem textBoxItem = sender as RadTextBoxItem;
        RadTextBoxElement textElement = textBoxItem.FindAncestor<RadTextBoxElement>();
        RadTextBox textBox = textElement.ElementTree.Control as RadTextBox;
    }

    If this is not what you meant, I would kindly ask you to provide some more details on your case and what you are trying to do.

    I am looking forward to you reply.

    Kind regards,
    Ivan Petrov
    the Telerik team
    RadControls for WinForms Q1'12 release is now live! Check out what's new or download a free trial >>
  3. UI for WinForms is Visual Studio 2017 Ready
  4. Marcus
    Marcus avatar
    17 posts
    Member since:
    Aug 2012

    Posted 19 Mar 2012 Link to this post

    Yes, you did understand me correctly. This solves it; thanks!

Back to Top