protected override bool ShouldGridTryToHandlePreviewKeyDown(KeyEventArgs e)
        {
            // return false to indicate the CurrentCellUIElement should handle the key
            // and the grid should ignore it.
            bool isControlKey = (e.KeyboardDevice.Modifiers & ModifierKeys.Control) != ModifierKeys.None;

            if (isControlKey)
            {
                return(true);
            }

            switch (e.Key)
            {
            case Key.Right:
            case Key.Left:
            case Key.Down:
            case Key.Up:
            {
                return(!CurrentCell.IsEditing);
            }

            case Key.End:
            case Key.Home:
            {
                CurrentCell.BeginEdit(true);
                return(false);
            }

            case Key.Delete:
            {
                CurrentCell.BeginEdit(true);
                return(false);
            }

            case Key.Enter:
            {
                if (this.CurrentCell.IsEditing)
                {
                    CurrentCell.EndEdit();
                }
                CurrentCell.MoveRight();
                return(true);
            }

            case Key.Back:
            {
                CurrentCell.BeginEdit(true);
                return(false);
            }
            }

            return(base.ShouldGridTryToHandlePreviewKeyDown(e));
        }
Example #2
0
        //set the value into the cell control & initialize it
        protected override void OnInitialize(int rowIndex, int colIndex)
        {
            // Immeditaly switch into editing mode when cell is initialized.
            GridStyleInfo style = Grid.Model[rowIndex, colIndex];

            if (style.CultureInfo != null)
            {
                dateTimePicker.Culture = style.CultureInfo;
            }
            dateTimePicker.Value = (DateTime)style.CellValue;
            CurrentCell.BeginEdit();
            base.OnInitialize(rowIndex, colIndex);
            dateTimePicker.ValueChanged  += new EventHandler(datePicker_ValueChanged);
            dateTimePicker.ShowDropButton = style.ShowButtons != GridShowButtons.Hide;
            dateTimePicker.Update();
        }
        protected override bool ShouldGridTryToHandlePreviewKeyDown(KeyEventArgs e)
        {
            // return false to indicate the CurrentCellUIElement should handle the key
            // and the grid should ignore it.
            bool isControlKey = (e.KeyboardDevice.Modifiers & ModifierKeys.Control) != ModifierKeys.None;

            if (isControlKey)
            {
                return(true);
            }

            switch (e.Key)
            {
            case Key.Right:
            case Key.Left:
            case Key.Down:
            case Key.Up:
            {
                // otherwise, move caret within textbox when cell is not in edit-mode.
                return(!CurrentCell.IsEditing);
            }

            case Key.End:
            case Key.Home:
            {
                CurrentCell.BeginEdit(true);
                return(false);
            }

            case Key.Delete:
            {
                CurrentCell.BeginEdit(true);
                return(false);
            }

            case Key.Enter:
            {
                if (this.CurrentStyle != null)
                {
                    GridDataStyleInfo sif = this.CurrentStyle.GridModel[this.CurrentCell.RowIndex, this.CurrentCell.ColumnIndex] as GridDataStyleInfo;
                    if (sif != null && sif.CellIdentity.TableCellType != GridDataTableCellType.AddNewRecordCell)
                    {
                        e.Handled = true;
                    }
                    else if (sif != null && sif.CellIdentity.TableCellType == GridDataTableCellType.AddNewRecordCell && !CurrentCell.IsEditing)
                    {
                        e.Handled = true;
                    }
                }
                if (this.CurrentCell.IsEditing)
                {
                    CurrentCell.EndEdit();
                }
                CurrentCell.MoveRight();

                return(true);

                break;
            }

            case Key.Back:
            {
                CurrentCell.BeginEdit(true);
                return(false);
            }
            break;
            }

            return(base.ShouldGridTryToHandlePreviewKeyDown(e));
        }
 protected override void OnGridPreviewTextInput(TextCompositionEventArgs e)
 {
     CurrentCell.ScrollInView();
     CurrentCell.BeginEdit(true);
 }