private void gvGrades_CellBeginEdit(object sender, Telerik.WinControls.UI.GridViewCellCancelEventArgs e)
 {
     if ((int)this.gvGrades.CurrentRow.Cells[2].Value > 0)
     {
         e.Cancel = true;
     }
 }
 private void owner_CellBeginEdit(object sender, GridViewCellCancelEventArgs e)
 {
     if (e.Column != this.cell.ColumnInfo || e.Row != this.cell.RowInfo)
     {
         return;
     }
     this.GetChild(0)?.Select(AccessibleSelection.TakeFocus);
 }
        private void gvDailyMeasures_CellBeginEdit(object sender, Telerik.WinControls.UI.GridViewCellCancelEventArgs e)
        {
            var measure = e.Row.DataBoundItem as DailyStandardMeasure;

            if (measure != null)
            {
                var editMeasure = CanEditMeasure(measure) && (e.Column.Name == "Value" || e.Column.Name == "FoodClassId");

                if (!editMeasure)
                {
                    e.Cancel = true;
                }
                else if (e.Column.Name == "FoodClassId")
                {
                    var value = e.Row.Cells["Value"].Value;
                    if (value == null)
                    {
                        e.Cancel = true;
                    }
                }
            }
        }
        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);
        }