您好,这个需要您重写下上下左右的事件
比如左移
- class MoveLeftction : FarPoint.Win.Spread.Action
- {
- public override void PerformAction(object source)
- {
- if (source is SpreadView)
- {
- SpreadView spread = (SpreadView)source;
- SheetView sheet = spread.Sheets[spread.ActiveSheetIndex];
- if (sheet.SelectionCount == 0 || (sheet.SelectionCount == 1 && sheet.GetSelection(0).ColumnCount == 1 && sheet.GetSelection(0).RowCount == 1))
- {
- var col = sheet.ActiveColumnIndex - 1;
- var row = sheet.ActiveRowIndex;
- if (sheet.Rows[row].Locked)
- {
- return;
- }
- while (true)
- {
- if (col > 0)
- {
- if (sheet.Cells[row, col].Locked == false && sheet.Columns[col].Locked == false)
- {
- break;
- }
- else
- {
- col--;
- }
- }
- else
- {
- break;
- }
- }
- if (sheet.Cells[row, col].Locked == false)
- {
- sheet.ClearSelection();
- sheet.SetActiveCell(row, col);
- }
- }
- else
- {
- sheet.ClearSelection();
- sheet.SetActiveCell(sheet.ActiveRowIndex, sheet.ActiveColumnIndex);
- }
- }
- }
- }
复制代码
初始化中添加
- InputMap im = fpSpread1.GetInputMap(InputMapMode.WhenFocused);
- ActionMap am = fpSpread1.GetActionMap();
- im.Put(new Keystroke(Keys.Left, Keys.None), "MoveLeft");
- am.Put("MoveLeft", new MoveLeftction());
复制代码 |