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

Get RadTextBox from RadTextBoxItem

2 Answers 120 Views
TextBox
This is a migrated thread and some comments may be shown as answers.
Marcus
Top achievements
Rank 1
Marcus asked on 16 Mar 2012, 04:12 PM

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 Answers, 1 is accepted

Sort by
0
Accepted
Ivan Petrov
Telerik team
answered on 19 Mar 2012, 10:00 AM
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 >>
0
Marcus
Top achievements
Rank 1
answered on 19 Mar 2012, 10:07 AM

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

Tags
TextBox
Asked by
Marcus
Top achievements
Rank 1
Answers by
Ivan Petrov
Telerik team
Marcus
Top achievements
Rank 1
Share this question
or