예제 #1
0
        protected override bool ProcessCmdKey(ref Message msg, Keys keyData)
        {
            if (keyData == Keys.Escape)
            {
                if (_control != null && _control.Visible == true) //如果有控件
                {
                    _control.Hide();                              //隐藏控件
                }
            }
            if (_control != null && _control.Visible)
            {
                #region 当前列表显示时候
                IFpInputable _editor = _control as IFpInputable;
                if (_editor != null)
                {
                    if (keyData == Keys.Up)
                    {
                        _editor.MovePrevious();
                    }
                    else if (keyData == Keys.Down)
                    {
                        _editor.MoveNext();
                    }
                    else if (keyData == Keys.PageUp)
                    {
                        _editor.PreviousPage();
                    }
                    else if (keyData == Keys.PageDown)
                    {
                        _editor.NextPage();
                    }
                    else if (keyData == Keys.Enter)
                    {
                        object obj = _editor.GetSelectedItem();
                        if (obj != null && obj.ToString() != "")
                        {
                            try
                            {
                                this.SheetView.ActiveCell.Tag  = obj;
                                this.SheetView.ActiveCell.Text = obj.ToString();
                            }
                            catch {}
                        }
                        _control.Hide();
                    }
                }
                #endregion
            }
            else            //没有列表时候,进行行列选择
            {
                if (keyData == Keys.Up)
                {
                    if (this.fpSpread1.Sheets[0].ActiveRowIndex > 0)
                    {
                        this.fpSpread1.Sheets[0].SetActiveCell(this.fpSpread1.Sheets[0].ActiveRowIndex - 1, this.fpSpread1.Sheets[0].ActiveColumnIndex);
                    }
                }
                else if (keyData == Keys.Down)
                {
                    if (this.fpSpread1.Sheets[0].ActiveRowIndex < this.fpSpread1.Sheets[0].RowCount - 1)
                    {
                        this.fpSpread1.Sheets[0].SetActiveCell(this.fpSpread1.Sheets[0].ActiveRowIndex + 1, this.fpSpread1.Sheets[0].ActiveColumnIndex);
                    }
                }
                else if (keyData == Keys.Left || keyData == Keys.Right)
                {
                    if (_control != null)
                    {
                        _control.Show();                                   //如果有控件没显示给显示出来
                    }
                }
            }
            if (this.IsAutoSkip && (keyData == Keys.Enter))
            {
                this.skip();
            }

            if (KeyPressEvent != null)
            {
                KeyPressEventArgs e = new KeyPressEventArgs((char)keyData.GetHashCode());
                KeyPressEvent(this, e);
            }


            return(base.ProcessCmdKey(ref msg, keyData));
        }