public bool WantsInputKey(Keys keyData)
{
// Tell MultiRow control that the cell will handle '+','-', and left, right key when edit status.
if (keyData == Keys.Add || keyData == Keys.Subtract || keyData == Keys.Left || keyData == Keys.Right)
{
return true;
}
return false;
}
protected override void OnKeyDown(CellKeyEventArgs e)
{
// Handle key board message when editing state.
if (this.GcMultiRow.CurrentCell.RowIndex == e.RowIndex &&
this.GcMultiRow.CurrentCell.CellIndex == e.CellIndex &&
this.GcMultiRow.IsCurrentCellInEditMode)
{
if (e.KeyData == Keys.Add || e.KeyData == Keys.Right)
{
this.EditingCellFormattedValue = _editingValue + 1;
}
else if (e.KeyData == Keys.Subtract || e.KeyData == Keys.Left)
{
this.EditingCellFormattedValue = _editingValue - 1;
}
base.OnKeyDown(e);
}
}
Public Function WantsInputKey(ByVal keyData As Keys) As Boolean Implements IEditingCell.WantsInputKey
' Tell MultiRow control that the cell will handle '+','-', and left, right key when edit status.
If keyData = Keys.Add OrElse keyData = Keys.Subtract OrElse keyData = Keys.Left OrElse keyData = Keys.Right Then
Return True
End If
Return False
End Function
Protected Overloads Overrides Sub OnKeyDown(ByVal e As CellKeyEventArgs)
' Handle key board message when editing state.
If Me.GcMultiRow.CurrentCell.RowIndex = e.RowIndex AndAlso Me.GcMultiRow.CurrentCell.CellIndex = e.CellIndex AndAlso Me.GcMultiRow.IsCurrentCellInEditMode Then
If e.KeyData = Keys.Add OrElse e.KeyData = Keys.Right Then
Me.EditingCellFormattedValue = _editingValue + 1
ElseIf e.KeyData = Keys.Subtract OrElse e.KeyData = Keys.Left Then
Me.EditingCellFormattedValue = _editingValue - 1
End If
MyBase.OnKeyDown(e)
End If
End Sub