在Spread中提供了一些内置的键盘事件,我们在使用Spread的时候,可以选择使用默认的键盘事件,也可以自己定义键盘事件。
在不使用默认键盘事件时,我们一般使用下面的代码:- FarPoint.Win.Spread.InputMap im = new FarPoint.Win.Spread.InputMap();
- im = fpSpread1.GetInputMap(FarPoint.Win.Spread.InputMapMode.WhenFocused);
- im.Put(new FarPoint.Win.Spread.Keystroke(Keys.Enter, Keys.None), FarPoint.Win.Spread.SpreadActions.MoveToNextRow);
-
- im = fpSpread1.GetInputMap(FarPoint.Win.Spread.InputMapMode.WhenAncestorOfFocused);
- im.Put(new FarPoint.Win.Spread.Keystroke(Keys.Enter, Keys.None), FarPoint.Win.Spread.SpreadActions.MoveToNextRow);
复制代码 不过修改默认的上、下、左、右键的事件有些不同之处,需要使用下面的代码:[code]private void Form1_Load(object sender, EventArgs e)
{
FarPoint.Win.Spread.InputMap im = new FarPoint.Win.Spread.InputMap();
im = fpSpread1.GetInputMap(FarPoint.Win.Spread.InputMapMode.WhenFocused);
im.Put(new FarPoint.Win.Spread.Keystroke(Keys.Down, Keys.None), FarPoint.Win.Spread.SpreadActions.None);
im = fpSpread1.GetInputMap(FarPoint.Win.Spread.InputMapMode.WhenAncestorOfFocused);
im.Put(new FarPoint.Win.Spread.Keystroke(Keys.Down, Keys.None), FarPoint.Win.Spread.SpreadActions.None);
}
protected override bool ProcessDialogKey(Keys keyData)
{
switch (keyData)
{
case Keys.Up:
case Keys.Down:
return false;
}
return base.ProcessDialogKey(keyData);
}
[code]
源码下载:
VS2010 + Spread for WinForms 6.0.3503
4603_Inputmap.zip
(9.87 KB, 下载次数: 1262)
|
|