Articles in this section
Category / Section

How to dispose a docking managers control which is already docked?

1 min read

 

We can dispose the docking manager controls using Application_Idle event. We have to keep track the docking managers control using ArrayList whenever the docking state is changed. After the state is changed the Application_Idle event gets fired, we can dispose a particular control by checking its state. The following code fragment shows an implementation for disposing off the floating windows.

C#

// ArrayList to keep track of floating docking windows to be disposed later

private ArrayList alDisposed = new ArrayList();

// Storing control in floating states

void dockingManager1_DragFeedbackStop(object sender, EventArgs e)

{

for (int i = 0; i < this.dockingManager1.ControlsArray.Length; i++)

{

ctrl = this.dockingManager1.ControlsArray[i];

if (dockingManager1.IsFloating(ctrl))

{

this.alDisposed.Add(ctrl);

}

}

}

// Dispose off the closed docking windows from within the Application.Idle event handler

void Application_Idle(object sender, EventArgs e)

{

int ncontrols = this.alDisposed.Count;

if (ncontrols > 0)

{

Control[] ctrlstodispose = (Control[])this.alDisposed.ToArray(typeof(Control));

this.alDisposed.Clear();

for (int i = 0; i < ncontrols; i++)

{

Control ctrl = ctrlstodispose[i];

this.dockingManager1.SetEnableDocking(ctrl, false);

this.Controls.Remove(ctrl);

ctrl.Dispose();

}

}

}

VB

' ArrayList to keep track of floating docking windows to be disposed later

Private alDisposed As ArrayList = New ArrayList()

' Storing control in floating states

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

Do

ctrl = Me.dockingManager1.ControlsArray(i)

If dockingManager1.IsFloating(ctrl) Then

Me.alDisposed.Add(ctrl)

End If

Loop

End Sub

' Dispose off the closed docking windows from within the Application.Idle event handler

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

Dim ncontrols As Integer = Me.alDisposed.Count

If ncontrols And gt; 0 Then

Dim ctrlstodispose As Control() = CType(Me.alDisposed.ToArray(GetType(Control)), Control())

Me.alDisposed.Clear()

Do

Dim ctrl As Control = ctrlstodispose(i)

Me.dockingManager1.SetEnableDocking(ctrl, False)

Me.Controls.Remove(ctrl)

ctrl.Dispose()

Loop

End If

End Sub

Please refer the sample in the below link which illustrates the above: http://help.syncfusion.com/support/samples/kb/tools.windows/39808/SampleProject.zip

Did you find this information helpful?
Yes
No
Help us improve this page
Please provide feedback or comments
Comments (0)
Please sign in to leave a comment
Access denied
Access denied