Focus floating toolwindow on form load

4 posts, 1 answers
  1. Arun Kumar
    Arun Kumar avatar
    60 posts
    Member since:
    Nov 2009

    Posted 27 Nov 2011 Link to this post

    How do I focus control inside toolwindow on form load ?
  2. Julian Benkov
    Admin
    Julian Benkov avatar
    1135 posts

    Posted 30 Nov 2011 Link to this post

    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.

  3. UI for WinForms is Visual Studio 2017 Ready
  4. Arun Kumar
    Arun Kumar avatar
    60 posts
    Member since:
    Nov 2009

    Posted 03 Dec 2011 Link to this post

    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 ? 


  5. Answer
    Julian Benkov
    Admin
    Julian Benkov avatar
    1135 posts

    Posted 07 Dec 2011 Link to this post

    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.

Back to Top