Resize a Docked Window when Changing it to a Float

6 posts, 0 answers
  1. Matt
    Matt avatar
    6 posts
    Member since:
    Oct 2014

    Posted 09 Apr 2015 Link to this post

    I have a RadDock with AutoDetectMdiChildren = True and MdiChildDocType = DockType.Document.

    When I drag one of the documents out of the RadDock and drop it on a different part of the screen, I want to change the size of the window. By default the size is very small.

    Is that possible and if so how would I accomplish this? 

     

  2. Stefan
    Admin
    Stefan avatar
    2891 posts

    Posted 10 Apr 2015 Link to this post

    Hello Matt,

    Thank you for writing.

    You can do that by using the FloatingWindowCreated event, where you can set its MinimumSize:
    void radDock1_FloatingWindowCreated(object sender, FloatingWindowEventArgs e)
    {
        e.Window.MinimumSize = new Size(1000, 1000);
    }

    I hope that you find this information useful. Should you have any other questions, do not hesitate to contact us.

    Regards,
    Stefan
    Telerik
     

    See What's Next in App Development. Register for TelerikNEXT.

     
  3. UI for WinForms is Visual Studio 2017 Ready
  4. Matt
    Matt avatar
    6 posts
    Member since:
    Oct 2014

    Posted 10 Apr 2015 in reply to Stefan Link to this post

    Follow-up question:

    Given that I'm using AutoDetectMdiChildren, how would I access properties on the form inside the floating window? I want to set the windows minimum size based on a property on the form. For example:

     

    e.Window.MinimumSize = e.Window.<reference to the form>.MinimumSize

     

    Thank you.

  5. Stefan
    Admin
    Stefan avatar
    2891 posts

    Posted 13 Apr 2015 Link to this post

    Hi Matt,

    Thank you for writing back.

    RadDock uses its own objects internally, so no reference to your form is passed in the FloatingWindowCreated event. The only place where you can access this form is in the TransactionCommitting event. Here is a small example I put for you:
    protected override void OnLoad(EventArgs e)
    {
        base.OnLoad(e);
     
        AddDock();
     
        this.IsMdiContainer = true;
        this.radDock1.AutoDetectMdiChildren = true;
     
        radDock1.FloatingWindowCreated += radDock1_FloatingWindowCreated;
        radDock1.TransactionCommitting += radDock1_TransactionCommitting;
    }
     
    Size minSize = Size.Empty;
    void radDock1_TransactionCommitting(object sender, RadDockTransactionCancelEventArgs e)
    {
        if(e.Transaction is FloatTransaction)
        {
            HostWindow hw = e.Transaction.AssociatedWindows[0] as HostWindow;
            Form mdiChild = hw.Content as Form;
            minSize = mdiChild.MinimumSize;
        }
    }
     
    void radDock1_FloatingWindowCreated(object sender, FloatingWindowEventArgs e)
    {
        e.Window.MinimumSize = minSize;
    }
     
    private void radButton1_Click(object sender, EventArgs e)
    {
        Form childForm = new Form();
        childForm.Text = "MDI Child " + DateTime.Now.ToShortTimeString();
        childForm.MdiParent = this;
        childForm.MinimumSize = new System.Drawing.Size(1000, 1000);
        childForm.Show();
    }

    I hope this helps.

    Regards,
    Stefan
    Telerik
     

    See What's Next in App Development. Register for TelerikNEXT.

     
  6. Matt
    Matt avatar
    6 posts
    Member since:
    Oct 2014

    Posted 24 Apr 2015 in reply to Stefan Link to this post

    Thanks Stefan, this is working great except the FloatWindow seems to have a limit to how small it can be when first created.

    For example: if my form's MinimumSize is 200, 200, but the FloatWindow created will always be ~ 290,260.

    Note the user can still manually resize the window to 200,200.

    Is there any way to allow the FloatWindow to be smaller when first created?

  7. Stefan
    Admin
    Stefan avatar
    2891 posts

    Posted 28 Apr 2015 Link to this post

    Hello Matt,

    There is a property called DefaultFloatingSize of a DockWindow, which you can set. For example you can use the TransactionCommitting event again with the following code, which will set this property for every window added:
    if (e.Transaction is DockWindowTransaction)
    {
        e.Transaction.AssociatedWindows[0].DefaultFloatingSize = new Size(200,200);
    }

    I hope this helps.

    Regards,
    Stefan
    Telerik
     

    See What's Next in App Development. Register for TelerikNEXT.

     
Back to Top
UI for WinForms is Visual Studio 2017 Ready