PowerTools MultiRow for Windows Forms 8.0J
KeyDown イベントの使用方法

TextBoxCellでTextBox.KeyDownイベントと同様の処理を行うには、TextBoxEditingControl.KeyDownイベントを使用します。
サンプルコード
Imports GrapeCity.Win.MultiRow

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    GcMultiRow1.Template = Template.Default
End Sub

Private Sub GcMultiRow1_EditingControlShowing(ByVal sender _
    As System.Object, ByVal e As EditingControlShowingEventArgs) _
    Handles GcMultiRow1.EditingControlShowing

    Dim textBox As TextBoxEditingControl = TryCast(e.Control, TextBoxEditingControl)
    If textBox IsNot Nothing Then
        RemoveHandler textBox.KeyDown, AddressOf Me.textBoxEditingControl_KeyDown
        AddHandler textBox.KeyDown, AddressOf Me.textBoxEditingControl_KeyDown
    End If
End Sub

Private Sub textBoxEditingControl_KeyDown(ByVal sender As System.Object, _
    ByVal e As KeyEventArgs)
    Console.WriteLine(e.KeyCode)
End Sub
using GrapeCity.Win.MultiRow;

private void Form1_Load(object sender, EventArgs e)
{
    gcMultiRow1.Template = Template.Default;
    gcMultiRow1.EditingControlShowing += new EventHandler<EditingControlShowingEventArgs>(gcMultiRow1_EditingControlShowing);
}

private void gcMultiRow1_EditingControlShowing(object sender, EditingControlShowingEventArgs e)
{
     TextBoxEditingControl textBox = e.Control as TextBoxEditingControl;
    if (textBox != null)
    {
        textBox.KeyDown -= new KeyEventHandler(textBox_KeyDown);
        textBox.KeyDown += new KeyEventHandler(textBox_KeyDown);
    }
}

private void textBox_KeyDown(object sender, KeyEventArgs e)
{
    Console.WriteLine(e.KeyCode);
}

セル編集コントロールのイベントで現在のセルを判別するには、IEditingControl.GcMultiRowプロパティを使用してセル編集コントロールをホストするGcMultiRowを取得します。

Private Sub textBoxEditingControl_KeyDown(ByVal sender As System.Object, _
    ByVal e As KeyEventArgs)
    Dim textBox1 As TextBoxEditingControl = TryCast(sender, TextBoxEditingControl)
    Console.WriteLine(textBox1.GcMultiRow.CurrentCellPosition.ToString())
End Sub
private void textBox_KeyDown(object sender, KeyEventArgs e)
{
    TextBoxEditingControl textBox1 = sender as TextBoxEditingControl;
    Console.WriteLine(textBox1.GcMultiRow.CurrentCellPosition.ToString());
}
   
参照

 

 


© 2008-2015 GrapeCity inc. All rights reserved.