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
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.
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.
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.
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?
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.