public bool MovementKey(ref Message msg, Keys keyData)
            {
                //move the selected cell based on the key pressed
                switch (keyData)
                {
                case Keys.Up:
                    if (_selectedRow - 1 < 0)
                    {
                        _selectedRow = 99;
                    }
                    _selectedRow--;
                    _ssp.SelectionChanged(_ssp);
                    break;

                case Keys.Down:
                    if (_selectedRow + 1 > 98)
                    {
                        _selectedRow = -1;
                    }
                    _selectedRow++;
                    _ssp.SelectionChanged(_ssp);
                    break;

                case Keys.Right:
                    if (_selectedCol + 1 > 25)
                    {
                        _selectedCol = -1;
                    }
                    _selectedCol++;
                    _ssp.SelectionChanged(_ssp);
                    break;

                case Keys.Left:
                    if (_selectedCol - 1 < 0)
                    {
                        _selectedCol = 26;
                    }
                    _selectedCol--;
                    _ssp.SelectionChanged(_ssp);
                    break;

                case Keys.Tab:
                    if (_selectedCol + 1 > 25)
                    {
                        _selectedCol = -1;
                    }
                    _selectedCol++;
                    _ssp.SelectionChanged(_ssp);
                    break;

                default:
                    return(false);
                }
                Invalidate();
                return(true);
            }
Exemplo n.º 2
0
            /// <summary>
            /// Determines which cell, if any, was clicked.  Generates a SelectionChanged event.  All of
            /// the indexes are zero based.
            /// </summary>
            /// <param name="e"></param>
            protected override void OnMouseClick(MouseEventArgs e)
            {
                base.OnClick(e);
                int x = (e.X - LABEL_COL_WIDTH) / DATA_COL_WIDTH;
                int y = (e.Y - LABEL_ROW_HEIGHT) / DATA_ROW_HEIGHT;

                if (e.X > LABEL_COL_WIDTH && e.Y > LABEL_ROW_HEIGHT && (x + _firstColumn < COL_COUNT) && (y + _firstRow < ROW_COUNT))
                {
                    _selectedCol = x + _firstColumn;
                    _selectedRow = y + _firstRow;
                    if (_ssp.SelectionChanged != null)
                    {
                        _ssp.SelectionChanged(_ssp);
                    }
                }
                Invalidate();
            }