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

RadTextbox name coming up blank in ActiveControl

1 Answer 130 Views
TextBox
This is a migrated thread and some comments may be shown as answers.
Karl
Top achievements
Rank 1
Karl asked on 22 Apr 2012, 06:51 AM

Hi,

Sorry if this issue has been posted and resolved before but I was unable to find it in the forum.

My issue is that when I search for the active control and it currently is a RadTextbox, the name comes up blank. Example below
private void radTextBox1_Enter(object sender, EventArgs e)
{
    MessageBox.Show(this.ActiveControl.Name);
}

I have tried this on Telerik Q3 2011 and Q1 2012 using different machines. Both test have been done on VS2010.

Thanks

1 Answer, 1 is accepted

Sort by
0
Accepted
Boryana
Telerik team
answered on 23 Apr 2012, 03:11 PM
Hi Karl,

Thank you for writing.

The issue you experience is a consequence of the complicated architecture of our controls. The editors in our suite hosts a standard MS TextBox control. This is the most secure approach to ensure that our controls mimic the behavior of the standard MS controls. In this sense, if you have a closer look at the ActiveControl when the message box pops up, you will see that ActiveControl is not a RadTextBox, but a HostedTextBoxBase. The same behavior will appear with the other editor controls, e.g. RadSpinEditor, RadDateTimePicker etc.

As a  workaround, I suggest to check the Name property of the ActiveControl and it if is not set, return the Name of its Parent:
string name = this.ActiveControl.Name;
if (name == "")
{
    name = this.ActiveControl.Parent.Name;
}

I hope this helps. Let me know if you encounter further issues. I will do my best to assist you.

Regards,
Boryana
the Telerik team
RadControls for WinForms Q1'12 release is now live! Check out what's new or download a free trial >>
Tags
TextBox
Asked by
Karl
Top achievements
Rank 1
Answers by
Boryana
Telerik team
Share this question
or