MESCIUS SPREAD for Windows Forms 17.0J サンプルコード集
非編集セルでのキー入力を検知する

MESCIUS SPREAD for Windows Forms 17.0J サンプルコード集 > キーボード操作(入力マップ) > 非編集セルでのキー入力を検知する

FpSpreadクラスのKeyDown/KeyPress/KeyUpイベント(いずれもSystem.Windows.Forms.Controlから継承)を利用することで、シート上での各キー入力を検知することができます。


 private void fpSpread1_KeyDown(object sender, System.Windows.Forms.KeyEventArgs e)
 {
   Console.WriteLine("KeyDownイベント:" + e.KeyCode.ToString());
 }

 private void fpSpread1_KeyPress(object sender, System.Windows.Forms.KeyPressEventArgs e)
 {
   Console.WriteLine("KeyPressイベント:" + e.KeyChar.ToString());
 }

 private void fpSpread1_KeyUp(object sender, System.Windows.Forms.KeyEventArgs e)
 {
   Console.WriteLine("KeyUpイベント:" + e.KeyCode.ToString());
 } 
 Private Sub FpSpread1_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles FpSpread1.KeyDown
   Console.WriteLine("KeyDownイベント:" + e.KeyCode.ToString)
 End Sub

 Private Sub FpSpread1_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles FpSpread1.KeyPress
   Console.WriteLine("KeyPressイベント:" + e.KeyChar.ToString)
 End Sub

 Private Sub FpSpread1_KeyUp(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles FpSpread1.KeyUp
   Console.WriteLine("KeyUpイベント:" + e.KeyCode.ToString)
 End Sub