RadTextbox name coming up blank in ActiveControl

2 posts, 1 answers
  1. Karl
    Karl avatar
    3 posts
    Member since:
    Apr 2012

    Posted 22 Apr 2012 Link to this post


    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
  2. Answer
    Boryana
    Admin
    Boryana avatar
    330 posts

    Posted 23 Apr 2012 Link to this post

    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 >>
  3. UI for WinForms is Visual Studio 2017 Ready
Back to Top