コード例 #1
0
        internal bool RaiseRowValidatingEvent(GridViewRowInfo row)
        {
            RowValidatingEventArgs args = new RowValidatingEventArgs(row);

            this.gridViewElement.Template.EventDispatcher.RaiseEvent <RowValidatingEventArgs>(EventDispatcher.RowValidating, (object)this, args);
            return(args.Cancel);
        }
コード例 #2
0
        protected override bool ProcessEnterKey(KeyEventArgs keys)
        {
            bool isInEditMode = this.GridViewElement.IsInEditMode;

            if (!isInEditMode && this.GridViewElement.BeginEditMode == RadGridViewBeginEditMode.BeginEditOnEnter)
            {
                return(this.GridViewElement.BeginEdit());
            }
            if (isInEditMode)
            {
                RadTextBoxEditor activeEditor = this.EditorManager.ActiveEditor as RadTextBoxEditor;
                if (activeEditor != null && activeEditor.AcceptsReturn)
                {
                    return(false);
                }
            }
            if (this.GridViewElement.NewRowEnterKeyMode == RadGridViewNewRowEnterKeyMode.None)
            {
                if (isInEditMode)
                {
                    this.GridViewElement.CloseEditor();
                }
                return(true);
            }
            GridViewNewRowInfo currentRow1 = (GridViewNewRowInfo)this.GridViewElement.CurrentRow;

            if (this.GridViewElement.NewRowEnterKeyMode == RadGridViewNewRowEnterKeyMode.EnterMovesToNextCell)
            {
                bool flag = !this.IsInEditMode;
                if (isInEditMode)
                {
                    if (this.IsOnLastCell())
                    {
                        currentRow1?.DeferUserAddedRow();
                        flag = this.GridViewElement.EndEdit();
                        if (currentRow1.RowPosition == SystemRowPosition.Bottom)
                        {
                            this.GridViewElement.UpdateLayout();
                            currentRow1.EnsureVisible();
                            this.Navigator.SelectFirstColumn();
                            flag = false;
                        }
                    }
                    else
                    {
                        flag = this.GridViewElement.CloseEditor();
                    }
                }
                if (flag)
                {
                    this.Navigator.SelectNextColumn();
                }
                currentRow1?.RaiseUserAddedRow();
                if (isInEditMode && this.GridViewElement.CurrentRow is GridViewNewRowInfo && this.GridViewElement.BeginEditMode != RadGridViewBeginEditMode.BeginEditProgrammatically)
                {
                    return(this.GridViewElement.BeginEdit());
                }
                return(false);
            }
            if (this.GridViewElement.NewRowEnterKeyMode == RadGridViewNewRowEnterKeyMode.EnterMovesToLastAddedRow)
            {
                currentRow1.MoveToLastRow = true;
            }
            if (!isInEditMode)
            {
                RowValidatingEventArgs args = new RowValidatingEventArgs((GridViewRowInfo)currentRow1);
                this.MasterTemplate.EventDispatcher.RaiseEvent <RowValidatingEventArgs>(EventDispatcher.RowValidating, (object)this, args);
                if (args.Cancel)
                {
                    return(false);
                }
                currentRow1?.DeferUserAddedRow();
                currentRow1.EndAddNewRow();
            }
            else
            {
                currentRow1?.DeferUserAddedRow();
                if (!this.GridViewElement.EndEdit())
                {
                    return(false);
                }
            }
            if (this.GridViewElement.NewRowEnterKeyMode == RadGridViewNewRowEnterKeyMode.EnterMovesToNextRow)
            {
                if (currentRow1.PinPosition == PinnedRowPosition.Bottom)
                {
                    this.EnsureLastRowVisible(currentRow1);
                }
                else if (currentRow1.RowPosition == SystemRowPosition.Bottom)
                {
                    this.GridViewElement.UpdateLayout();
                    currentRow1.EnsureVisible();
                }
                else
                {
                    EventDispatcher eventDispatcher = currentRow1.ViewTemplate.MasterTemplate.EventDispatcher;
                    eventDispatcher.SuspendEvent(EventDispatcher.CellValidating);
                    eventDispatcher.SuspendEvent(EventDispatcher.CellValidated);
                    eventDispatcher.SuspendEvent(EventDispatcher.RowValidating);
                    eventDispatcher.SuspendEvent(EventDispatcher.RowValidated);
                    GridViewRowInfo currentRow2;
                    GridViewRowInfo currentRow3;
                    do
                    {
                        currentRow2 = ((BaseGridNavigator)this.Navigator).MasterTemplate.CurrentRow;
                        this.Navigator.SelectNextRow(1);
                        currentRow3 = ((BaseGridNavigator)this.Navigator).MasterTemplate.CurrentRow;
                    }while (!(currentRow3 is GridViewDataRowInfo) && !(currentRow3 is GridViewGroupRowInfo) && currentRow3 != currentRow2);
                    eventDispatcher.ResumeEvent(EventDispatcher.CellValidating);
                    eventDispatcher.ResumeEvent(EventDispatcher.CellValidated);
                    eventDispatcher.ResumeEvent(EventDispatcher.RowValidating);
                    eventDispatcher.ResumeEvent(EventDispatcher.RowValidated);
                }
            }
            currentRow1?.RaiseUserAddedRow();
            return(false);
        }