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

RadDock cause wrong Form's ActiveControl

1 Answer 93 Views
Dock
This is a migrated thread and some comments may be shown as answers.
Chris
Top achievements
Rank 1
Veteran
Iron
Iron
Chris asked on 28 Dec 2018, 02:23 AM

HI

I have met a problem about WinForm ActiveControl in Telerik Control - RadDock.

Reintroduce steps :

1.Place TextBox1, TextBox2 on Form.
2a.Place a RadDock on Form.
2b.RadDock task - Dock New Window to Left - toolWindow1
2c.RadDock task - Add Tabbed Document - documentWindow1
3a.Place TextBox3 on toolWindow1.
3b.Place TextBox4 on documentWindow1.

Run the application and test the ActiveControl state (focus the control by control),
ActiveControl of TextBox1 and TextBox2 is CORRECT,
but ActiveControl of TextBox3 and TextBox4 was WRONG.
(see attachment - Telerik ActiveControl err1.png).

Why the ActiveControl are not TextBox3/TextBox4 ? 
And Is there have any solution to fix that ?

Code :


    private void Timer1_Tick(object sender, EventArgs e)
    {
      Control CurrentActiveControl = ActiveControl;
      string sActiveControlName, sActiveControlString;
      //
      sActiveControlName = (CurrentActiveControl != null) ? CurrentActiveControl.Name : "(unknown)";
      sActiveControlString = (CurrentActiveControl != null) ? CurrentActiveControl.ToString() : "(none)";
      //
      listBox1.Items.Insert(0, DateTime.Now.ToString("hh:mm:ss - ") + sActiveControlName + ", " + sActiveControlString);
    }

*Visual Studio 2015 Enterprise Update 3
*Telerik UI for WinForms R1 2018

Best regards

Chris

 

 

 

1 Answer, 1 is accepted

Sort by
0
Accepted
Dess | Tech Support Engineer, Principal
Telerik team
answered on 28 Dec 2018, 11:39 AM
Hello, Chris, 

Indeed, the ActiveControl property of the form returns the respective ToolWindow/DocumentWindow when a control inside the RadDock is focused. When a window is activated, the NativeMethods.GetFocus method is used to get the handle to the window that has the focus. Then this control is returned by using the Control.FromChildHandle

Note that the ToolWindow is a derivative of the ContainerControl. After some research, I have found that the ActiveControl is always returned to be the ContainerControl for the Form.ActiveControl property, not the hosted control inside. Please refer to the following threads which are quite useful on this topic: 
http://www.yortondotnet.com/2007/01/when-activecontrol-is-not-active.html

The ContainerControl has its own ActiveControl property that will give you the desired focused control. Please have in min that RadTextBox hosts the standard Ms TextBox. Hence, it is expected to be returned as the ContainerControl.ActiveControl.

I hope this information helps. If you need any further assistance please don't hesitate to contact me. 

Regards,
Dess | Tech Support Engineer, Sr.
Progress Telerik
Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
Tags
Dock
Asked by
Chris
Top achievements
Rank 1
Veteran
Iron
Iron
Answers by
Dess | Tech Support Engineer, Principal
Telerik team
Share this question
or