protected override void RemoveElement(int position) { GridVirtualizedCellElement child = this.Children[position] as GridVirtualizedCellElement; if (child != null) { if (child.RowElement == null || child.TableElement == null || (child.GridViewElement == null || child.GridViewElement.EditorManager == null) || !child.GridViewElement.IsInEditMode) { base.RemoveElement(position); return; } IEditableCell editableCell = child as IEditableCell; if (editableCell != null && editableCell.Editor != null && editableCell.Editor == child.GridViewElement.EditorManager.ActiveEditor) { child.GridViewElement.EditorManager.CancelEdit(); } } base.RemoveElement(position); }
public CellValueSetter(IEditableCell cell) { _cell = cell; }
public static CellValueSetter Of(IEditableCell cell) { return(new CellValueSetter(cell)); }
public virtual bool BeginEdit() { GridCellElement currentCell = this.gridViewElement.CurrentView.CurrentCell; IEditableCell editableCell = currentCell as IEditableCell; if (this.IsInEditMode || editableCell == null || (!editableCell.IsEditable || currentCell == null) || (currentCell.RowInfo == null || currentCell.ViewInfo.ChildRows.Count == 0 && currentCell.RowInfo is GridViewDataRowInfo)) { return(false); } bool flag = this.IsPermanentEditor(currentCell.ColumnInfo.GetDefaultEditorType()); this.editModeInitialized = false; IInputEditor inputEditor1 = flag ? editableCell.Editor : this.GetDefaultEditor((IEditorProvider)currentCell.ColumnInfo); if (inputEditor1 == null) { return(false); } this.ActiveEditor = inputEditor1; GridViewCellCancelEventArgs args = new GridViewCellCancelEventArgs(currentCell, this.activeEditor); this.gridViewElement.Template.EventDispatcher.RaiseEvent <GridViewCellCancelEventArgs>(EventDispatcher.CellBeginEdit, (object)this, args); if (args.Cancel) { this.ActiveEditor = (IInputEditor)null; return(false); } this.gridViewElement.CurrentView.EnsureCellVisible(currentCell.RowInfo, currentCell.ColumnInfo); this.gridViewElement.UpdateLayout(); if (this.gridViewElement.CurrentCell == null || this.gridViewElement.CurrentCell.RowInfo == null) { return(false); } if (currentCell != this.gridViewElement.CurrentCell || this.ActiveEditor == null) { currentCell = (GridCellElement)this.gridViewElement.CurrentCell; editableCell = currentCell as IEditableCell; IInputEditor inputEditor2 = this.IsPermanentEditor(currentCell.ColumnInfo.GetDefaultEditorType()) ? editableCell.Editor : this.GetDefaultEditor((IEditorProvider)currentCell.ColumnInfo); if (inputEditor2 == null) { return(false); } this.ActiveEditor = inputEditor2; } if (currentCell.RowInfo is GridViewNewRowInfo) { currentCell.RowInfo.CallOnBeginEdit(); } editableCell.AddEditor(this.activeEditor); BaseGridEditor activeEditor = this.ActiveEditor as BaseGridEditor; activeEditor?.SetIsInBeginEditMode(true); currentCell.UpdateLayout(); if (this.gridViewElement.AutoSizeRows) { GridViewRowInfo rowInfo = currentCell.RowInfo; this.oldRowHeight = currentCell.RowInfo.Height; rowInfo.SuspendPropertyNotifications(); rowInfo.Height = (int)currentCell.RowElement.DesiredSize.Height; rowInfo.ResumePropertyNotifications(); currentCell.TableElement.ViewElement.UpdateRows(); } this.InitializeEditor(this.activeEditor); activeEditor?.SetIsInBeginEditMode(false); this.activeEditor.BeginEdit(); currentCell.RowElement.UpdateInfo(); this.editModeInitialized = true; return(true); }