public override void Dispose() {
     ColumnCreated = null;
     CustomCreateColumn = null;
     GridDataSourceChanging = null;
     if (popupMenu != null) {
         popupMenu.Dispose();
         popupMenu = null;
     }
     columnsProperties.Clear();
     if (layoutView != null) {
         layoutView.FocusedRowChanged -= new FocusedRowChangedEventHandler(LayoutView_FocusedRowChanged);
         layoutView.SelectionChanged -= new SelectionChangedEventHandler(LayoutView_SelectionChanged);
         layoutView.ShowingEditor -= new CancelEventHandler(LayoutView_EditorShowing);
         layoutView.ShownEditor -= new EventHandler(LayoutView_ShownEditor);
         layoutView.HiddenEditor -= new EventHandler(LayoutView_HiddenEditor);
         layoutView.MouseDown -= new MouseEventHandler(LayoutView_MouseDown);
         layoutView.MouseUp -= new MouseEventHandler(LayoutView_MouseUp);
         layoutView.Click -= new EventHandler(LayoutView_Click);
         layoutView.ValidateRow -= new ValidateRowEventHandler(LayoutView_ValidateRow);
         layoutView.InitNewRow -= new InitNewRowEventHandler(LayoutView_InitNewRow);
         layoutView.Dispose();
         layoutView = null;
     }
     if (grid != null) {
         if (grid.DataSource is IBindingList) {
             ((IBindingList)grid.DataSource).ListChanged -= new ListChangedEventHandler(DataSource_ListChanged);
         }
         grid.DataSource = null;
         grid.VisibleChanged -= new EventHandler(grid_VisibleChanged);
         grid.KeyDown -= new KeyEventHandler(grid_KeyDown);
         grid.HandleCreated -= new EventHandler(grid_HandleCreated);
         grid.DoubleClick -= new EventHandler(grid_DoubleClick);
         grid.ParentChanged -= new EventHandler(grid_ParentChanged);
         grid.RepositoryItems.Clear();
         grid.Dispose();
         grid = null;
     }
     base.Dispose();
 }
 private XafLayoutView CreateLayotView() {
     layoutView = new XafLayoutView();
     layoutView.TemplateCard = new LayoutViewCard();
     layoutView.ErrorMessages = ErrorMessages;
     layoutView.ShowingEditor += new CancelEventHandler(LayoutView_EditorShowing);
     layoutView.ShownEditor += new EventHandler(LayoutView_ShownEditor);
     layoutView.HiddenEditor += new EventHandler(LayoutView_HiddenEditor);
     layoutView.MouseDown += new MouseEventHandler(LayoutView_MouseDown);
     layoutView.MouseUp += new MouseEventHandler(LayoutView_MouseUp);
     layoutView.FocusedRowChanged += new FocusedRowChangedEventHandler(LayoutView_FocusedRowChanged);
     layoutView.SelectionChanged += new SelectionChangedEventHandler(LayoutView_SelectionChanged);
     layoutView.Click += new EventHandler(LayoutView_Click);
     layoutView.MouseWheel += new MouseEventHandler(LayoutView_MouseWheel);
     if (editMode == EditMode.Editable) {
         layoutView.ValidateRow += new ValidateRowEventHandler(LayoutView_ValidateRow);
         layoutView.InitNewRow += new InitNewRowEventHandler(LayoutView_InitNewRow);
     }
     layoutView.OptionsBehavior.EditorShowMode = DevExpress.Utils.EditorShowMode.Click;
     layoutView.OptionsBehavior.Editable = true;
     layoutView.OptionsBehavior.AutoSelectAllInEditor = false;
     layoutView.OptionsBehavior.AutoPopulateColumns = false;
     layoutView.OptionsBehavior.FocusLeaveOnTab = true;
     layoutView.OptionsSelection.MultiSelect = true;
     layoutView.ShowButtonMode = ShowButtonModeEnum.ShowOnlyInEditor;
     layoutView.ActiveFilterEnabled = ((IModelListViewWin)Model).IsActiveFilterEnabled;
     return layoutView;
 }