回复 5楼zjutwb的帖子
试试下面的代码:
- this.fpSpread1.KeyDown += new KeyEventHandler(spread_KeyDown);
- private void spread_KeyDown(object source, KeyEventArgs e)
- {
- if (e.KeyCode == Keys.Delete)
- {
- FpSpread spread = (FpSpread)source;
- int selectionCount = spread.ActiveSheet.SelectionCount;
- if (selectionCount > 0)
- {
- for (int i = 0; i < selectionCount; i++)
- {
- CellRange range = spread.ActiveSheet.GetSelection(i);
- spread.ActiveSheet.ClearRange(range.Row, range.Column, range.RowCount, range.ColumnCount, true);
- }
- }
- else
- {
- int activeRow = spread.ActiveSheet.ActiveRowIndex;
- int activeColumn = spread.ActiveSheet.ActiveColumnIndex;
- spread.ActiveSheet.ClearRange(activeRow, activeColumn, 1, 1, true);
- }
- e.Handled = true;
- }
- }
复制代码 |