You can perform processing similar to the TextBox.KeyDown event in the text box cell by using the TextBoxEditingControl.KeyDown event.
Using Code
This example uses the KeyDown event.
[VB]
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
|
[CS]
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);
}
|
To determine which current cell is using the cell edit control events, you can use the IEditingControl.GcMultiRow property and get the GcMultiRow that hosts the cell edit control.
Using Code
This example gets the current cell in the KeyDown event.
[VB]
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
|
[CS]
private void textBox_KeyDown(object sender, KeyEventArgs e)
{
TextBoxEditingControl textBox1 = sender as TextBoxEditingControl;
Console.WriteLine(textBox1.GcMultiRow.CurrentCellPosition.ToString());
}
|
See Also