private void ReleaseControl() { if (_currentControl != null) { _currentControl.Hide(); _currentControl.Parent = null; _currentControl.Dispose(); _currentControl = null; } }
private void widgetViewMain_DocumentClosing(object sender, DevExpress.XtraBars.Docking2010.Views.DocumentCancelEventArgs e) { ////MessageBox.Show("widgetViewMain_DocumentClosing"); if (sender is WidgetView) { WidgetView senderWidgetView = sender as WidgetView; foreach (Document eachDocument in senderWidgetView.Documents) { if (eachDocument.Control is UserControl1) { UserControl1 XtraUserControl = eachDocument.Control as UserControl1; { XtraUserControl.Dispose(); XtraUserControl = null; } break; } else if (eachDocument.Control is XtraUserControl) { XtraUserControl XtraUserControl = eachDocument.Control as XtraUserControl; { XtraUserControl.Dispose(); XtraUserControl = null; } break; } else if (eachDocument.Control is UserControl) { UserControl UserControl = eachDocument.Control as UserControl; { UserControl.Dispose(); UserControl = null; } break; } } } }