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

Focus floating toolwindow on form load

3 Answers 107 Views
Dock
This is a migrated thread and some comments may be shown as answers.
Arun Kumar
Top achievements
Rank 2
Arun Kumar asked on 27 Nov 2011, 07:07 AM
How do I focus control inside toolwindow on form load ?

3 Answers, 1 is accepted

Sort by
0
Julian Benkov
Telerik team
answered on 30 Nov 2011, 03:58 PM
Hi Arun Kumar,

To focus a child control in ToolWindow or any parent window, you must call Focus method in the Load event. Here is a simple example:

public partial class DockForm5 : Form
{
    private TextBox textBox;
 
    public DockForm5()
    {
        InitializeComponent();
 
        ToolWindow tool = new ToolWindow("123");
        
        ComboBox box = new ComboBox();
        box.Items.Add("1");
        box.Items.Add("2");
        box.Items.Add("3");
        tool.Controls.Add(box);
 
        RadDropDownList list = new RadDropDownList();
        list.Items.Add("1");
        list.Items.Add("2");
        list.Items.Add("3");
        list.Location = new Point(50, 50);
        tool.Controls.Add(list);
 
        RadDateTimePicker picker = new RadDateTimePicker();
        picker.Location = new Point(50, 90);
        tool.Controls.Add(picker);
        radDock1.DockWindow(tool, DockPosition.Left);
 
        tool = new ToolWindow("333");
        textBox = new TextBox();
        tool.Controls.Add(textBox);
 
        radDock1.DockWindow(tool, DockPosition.Bottom);
        radDock1.AddDocument(new DocumentWindow("test"));
    }
 
    protected override void OnLoad(EventArgs e)
    {
        base.OnLoad(e);
 
        textBox.Focus();
    }
}

I hopo this helps.

All the best,
Julian Benkov
the Telerik team

Q3’11 of RadControls for WinForms is available for download (see what's new). Get it today.

0
Arun Kumar
Top achievements
Rank 2
answered on 03 Dec 2011, 08:15 AM
Hi Julian Benkov,

Thanks for your reply.

I have floating toolwindow. In form load event, I use the RadDock.FloatWindow method to show the toolwindow. It shows the window on form load but it is not focused. Only if I click the window it gets activated. I want the window activated by default. So I can focus the textbox placed inside the toolwindow. How do I do that ? 


0
Accepted
Julian Benkov
Telerik team
answered on 07 Dec 2011, 01:25 PM
Hello Arun,

For this functionality you can use the Shown event of From instead of the Load event. Here is a simple example:

protected override void OnShown(EventArgs e)
{
    base.OnShown(e);
 
    radDock1.FloatWindow(toolWindow);
    toolWindow.FloatingParent.Activate();
}

Let me know if you need further assistance.

All the best,
Julian Benkov
the Telerik team

Q3’11 of RadControls for WinForms is available for download (see what's new). Get it today.

Tags
Dock
Asked by
Arun Kumar
Top achievements
Rank 2
Answers by
Julian Benkov
Telerik team
Arun Kumar
Top achievements
Rank 2
Share this question
or