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

Resize a Docked Window when Changing it to a Float

5 Answers 134 Views
Dock
This is a migrated thread and some comments may be shown as answers.
Matt
Top achievements
Rank 1
Matt asked on 09 Apr 2015, 08:46 PM

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? 

 

5 Answers, 1 is accepted

Sort by
0
Stefan
Telerik team
answered on 10 Apr 2015, 09:51 AM
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.

 
0
Matt
Top achievements
Rank 1
answered on 10 Apr 2015, 08:31 PM

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.

0
Stefan
Telerik team
answered on 13 Apr 2015, 10:00 AM
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.

 
0
Matt
Top achievements
Rank 1
answered on 24 Apr 2015, 07:32 PM

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?

0
Stefan
Telerik team
answered on 28 Apr 2015, 11:50 AM
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.

 
Tags
Dock
Asked by
Matt
Top achievements
Rank 1
Answers by
Stefan
Telerik team
Matt
Top achievements
Rank 1
Share this question
or