GrapeCity.Win.MultiRow Namespace > Cell Class : OnKeyDown Method |
Protected Overridable Sub OnKeyDown( _ ByVal e As CellKeyEventArgs _ )
Dim instance As Cell Dim e As CellKeyEventArgs instance.OnKeyDown(e)
protected virtual void OnKeyDown( CellKeyEventArgs e )
Raising an event invokes the event handler through a delegate.
The OnKeyDown method also allows derived classes to handle the event without attaching a delegate. This is the preferred technique for handling the event in a derived class.
Notes to Inheritors: When overriding OnKeyDown in a derived class, be sure to call the base class's OnKeyDown method so that registered delegates receive the event.
protected override void OnKeyDown(CellKeyEventArgs e) { // Handle keyboard message in edit mode. 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); } }
Protected Overloads Overrides Sub OnKeyDown(ByVal e As CellKeyEventArgs) ' Handle keyboard message in edit mode. 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
Target Platforms: Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2