RedSeoyeon 님, 안녕하세요.
그레이프시티입니다.
FarPoint.Win.Spread.InputMap 클래스와, FarPoint.Win.Spread.ActionMap 클래스를 사용하여, ESC 키를 눌렀을 때 처리하고자 하는 동작을 사용자 정의할 수 있습니다.
하기 샘플 코드에서는, ESC 키를 눌렀을 경우 메세지박스가 보여지도록 하는 동작을 사용자정의하여 사용하고 있습니다.
private void Form1_Load(object sender, EventArgs e)
{
FarPoint.Win.Spread.InputMap im = fpSpread1.GetInputMap(FarPoint.Win.Spread.InputMapMode.WhenFocused);
im.Put(new FarPoint.Win.Spread.Keystroke(Keys.Escape, Keys.None), "CustomAction");
im = fpSpread1.GetInputMap(FarPoint.Win.Spread.InputMapMode.WhenAncestorOfFocused);
im.Put(new FarPoint.Win.Spread.Keystroke(Keys.Escape, Keys.None), "CustomAction");
FarPoint.Win.Spread.ActionMap am = fpSpread1.GetActionMap();
am.Put("CustomAction", new CustomAction());
}
private class CustomAction : FarPoint.Win.Spread.Action
{
public override void PerformAction(object source)
{
if (source is FarPoint.Win.Spread.SpreadView)
{
// 원하는 동작 구현
MessageBox.Show("ESC 키 눌림");
}
}
}
또는 Spread에서 사용할 수 있도록 SpreadActions 클래스에 미리 정의된 동작을 적용할수도 있습니다.
하기 샘플 코드 적용 시, 셀이 편집모드에 있을 때 ESC키를 입력하면 편집모드가 종료됩니다. (기본 동작은 편집 취소 입니다.)
FarPoint.Win.Spread.InputMap im = fpSpread1.GetInputMap(FarPoint.Win.Spread.InputMapMode.WhenAncestorOfFocused);
im.Put(new FarPoint.Win.Spread.Keystroke(Keys.Escape, Keys.None), FarPoint.Win.Spread.SpreadActions.StopEditing);
자세한 내용은 아래에 링크된 온라인 스터디 게시글과 도움말 문서를 참고하여주시기 바랍니다.
[온라인 스터디] Winforms 키보드 상호작용
[Spread.NET v10 도움말] 기본 키 입력 처리
추가로 궁금하신 점이 있을 경우, 문의주시기 바랍니다.
감사합니다.
그레이프시티 드림