Floating Form in radDock

5 posts, 0 answers
  1. Badrane
    Badrane avatar
    3 posts
    Member since:
    Jun 2016

    Posted 06 Jun Link to this post

    radDock Position = Fill, Top, Bottom......

    I want the loaded form will be in floatting mode without drag and drop it in the radDok.

    I tried with the below code but I am not satisfied:

    <p>var frmBrand = new FormBrand();<br>frmBrand.Text = @"Brand::  ";v<br>HostWindow host = radDock1.DockControl(frmBrand, new DockPosition()); </p><p>//HostWindow host = radDock1.DockControl(frmBrand, DockPosition.Left)<br>host.DockState = DockState.Docked;<br>radDock1.AutoDetectMdiChildren = true;<br><br>frmBrand.Show();</p>

  2. Badrane
    Badrane avatar
    3 posts
    Member since:
    Jun 2016

    Posted 06 Jun in reply to Badrane Link to this post

    1.var frmBrand = new FormBrand();
    2.frmBrand.Text = @"Brand:: ";
    3.HostWindow host = radDock1.DockControl(frmBrand, new DockPosition());
    4.//HostWindow host = radDock1.DockControl(frmBrand, DockPosition.Left)
    5.host.DockState = DockState.Docked;
    6.radDock1.AutoDetectMdiChildren = true;
    7.frmBrand.Show();

  3. UI for WinForms is Visual Studio 2017 Ready
  4. Dimitar
    Admin
    Dimitar avatar
    1410 posts

    Posted 07 Jun Link to this post

    Hi Badrane,

    Thank you for writing.

    You need to set the DockState to Floating. For example:
    private void radButton1_Click(object sender, EventArgs e)
    {
        Form form = new Form();
        form.BackColor = Color.Pink;
        form.Text = "My Form";
        var host = this.radDock1.DockControl(form, DockPosition.Left);
        form.Show();
     
        host.DockState = DockState.Floating;
     
    }

    The following article shows how you can work with the MDI mode: Automatic MDI Form Handling.

    I hope this will be useful. 

    Regards,
    Dimitar
    Telerik
    Check out the Windows Forms project converter, which aids the conversion process from standard Windows Forms applications written in C# or VB to Telerik UI for WinForms.For more information check out this blog post and share your thoughts.
  5. Badrane
    Badrane avatar
    3 posts
    Member since:
    Jun 2016

    Posted 08 Jun in reply to Dimitar Link to this post

    First, Thank you.

    1- The DockPosition was in the left and after that was detached and moved to the middle?

    I want to see the form Floating without any DockPosition value.

    2- The form have lost its origin size (high, width)? why, I tried to restore it in the run time without success

    frmBrand.Size = new Size(495, 287);

  6. Dimitar
    Admin
    Dimitar avatar
    1410 posts

    Posted 09 Jun Link to this post

    Hi Badrane,

    There is no way to directly add floating window without docking it first. To overcome this limitation you can show a separate form and then dock it when necessary.

    Another approach would be to change the dock state of a DockWindow which will work faster and the change would not be so obvious:
    DocumentWindow window = new DocumentWindow();
     
    window.BackColor = Color.Pink;
    window.Text = "My Form";
     
    var host = this.radDock1.DockControl(window, DockPosition.Left);
    host.DockState = DockState.Floating;

    In addition, you can use the FloatingWindowCreated to change the size:
    private void RadDock1_FloatingWindowCreated(object sender, FloatingWindowEventArgs e)
    {
        e.Window.MinimumSize = new Size(800, 800);
    }

    I hope this will be useful. 

    Regards,
    Dimitar
    Telerik
    Check out the Windows Forms project converter, which aids the conversion process from standard Windows Forms applications written in C# or VB to Telerik UI for WinForms.For more information check out this blog post and share your thoughts.
Back to Top
UI for WinForms is Visual Studio 2017 Ready