We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on : Nov 16th 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

How to hide a floating window in MDI Child form when minimizing it?

 

Docking Manager does not have any special property for doing this, but forms SizeChanged event will provide the option to hide floating window when minimize the MDI child form. When the form size goes to minimized state, set the SetDockVisibility to false and call the SaveDockStateInfo method or else SetDockVisibility to true and call LoadDockStateInfo. Please refer the below code snippet which illustartes this:

C#

void Form1_SizeChanged(object sender, EventArgs e)

{

Console.WriteLine("Form1 size changed event triggered");

//Checks if the window state is minimized. If it is true,Dock visibility is false.

//otherwise visibility set to true.

if (this.WindowState == FormWindowState.Minimized)

{

this.SaveDockStateInfo();

this.dockingManager1.SetDockVisibility(this.panel1, false);

}

else

{

this.dockingManager1.SetDockVisibility(this.panel1, true);

this.LoadDockStateInfo();

}

}

VB

Private Sub Form1_SizeChanged(ByVal sender As Object, ByVal e As EventArgs)

Console.WriteLine("Form1 size changed event triggered")

'Checks if the window state is minimized. If it is true,Dock visibility is false.

'otherwise visibility set to true.

If Me.WindowState = FormWindowState.Minimized Then

Me.SaveDockStateInfo()

Me.DockingManager1.SetDockVisibility(Me.Panel1, False)

Else

Me.DockingManager1.SetDockVisibility(Me.Panel1, True)

Me.LoadDockStateInfo()

End If

End Sub

The below code snippet is used, when there are multiple controls on the form:

C#

private void Form1_SizeChanged(object sender, System.EventArgs e)

{

Console.WriteLine("Form3 size changed event triggered");

//Collects the list of docked controls in the form.

IEnumerator ienum = this.dockingManager1.Controls;

ArrayList dockedctrls = new ArrayList();

while(ienum.MoveNext())

dockedctrls.Add(ienum.Current);

if(this.WindowState==FormWindowState.Minimized)

{

//Set the visibility to false for minimised state

this.SaveDockState();

foreach(Control ctrl in dockedctrls)

{

this.dockingManager1.SetDockVisibility(ctrl,false);

}

}

else

{

//Set the visibility to true for maximised and normal state

foreach(Control ctrl in dockedctrls)

{

this.dockingManager1.SetDockVisibility(ctrl,true);

}

this.LoadDockState();

}

}

VB

Private Sub Form1_SizeChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.SizeChanged

Console.WriteLine("Form3 size changed event triggered")

'Collects the list of docked controls in the form.

Dim ienum As IEnumerator = Me.dockingManager1.Controls

Dim dockedctrls As ArrayList = New ArrayList()

Do While ienum.MoveNext()

dockedctrls.Add(ienum.Current)

Loop

If Me.WindowState=FormWindowState.Minimized Then

'Set the visibility to false for minimised state

Me.SaveDockState()

For Each ctrl As Control In dockedctrls

Me.dockingManager1.SetDockVisibility(ctrl,False)

Next ctrl

Else

'Set the visibility to true for maximised and normal state

For Each ctrl As Control In dockedctrls

Me.dockingManager1.SetDockVisibility(ctrl,True)

Next ctrl

Me.LoadDockState()

End If

End Sub

Sample:

http://help.syncfusion.com/support/samples/KB/Tools.Windows/TDFormSize/FormSize.zip

Article ID: Published Date: Last Revised Date: Platform: Control:
1269 04/30/2011 07/10/2014 WinForms DockingManager
Tags:
Did you find this information helpful?
Add Comment
You must log in to leave a comment

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon