GrapeCity.Win.MultiRow Namespace > Cell Class : OnMouseDown Method |
Protected Overridable Sub OnMouseDown( _ ByVal e As CellMouseEventArgs _ )
Dim instance As Cell Dim e As CellMouseEventArgs instance.OnMouseDown(e)
protected virtual void OnMouseDown( CellMouseEventArgs e )
Raising an event invokes the event handler through a delegate.
The OnMouseDown 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 OnMouseDown in a derived class, be sure to call the base class's OnMouseDown method so that registered delegates receive the event.
bool _beginMouseDraging = false; protected override void OnMouseDown(CellMouseEventArgs e) { // Override OnMouseDown method to customize the action. if (e.Button == MouseButtons.Left) { // Assert the cell is current cell. if (this.GcMultiRow.CurrentCell.RowIndex == e.RowIndex && this.GcMultiRow.CurrentCell.CellIndex == e.CellIndex) { bool beginEditSuccess = this.GcMultiRow.BeginEdit(false); if (beginEditSuccess) { this.EditingCellFormattedValue = this.GetValueFromPoint(e.Location); this._beginMouseDraging = true; } } } base.OnMouseDown(e); } protected override void OnMouseMove(CellMouseEventArgs e) { if (this._beginMouseDraging) { // Drag mouse to change the EditingCellFormattedValue. this.EditingCellFormattedValue = this.GetValueFromPoint(e.Location); } base.OnMouseMove(e); } protected override void OnMouseUp(CellMouseEventArgs e) { // When mouse is up, end dragging. this._beginMouseDraging = false; base.OnMouseUp(e); }
Private _beginMouseDraging As Boolean = False Protected Overloads Overrides Sub OnMouseDown(ByVal e As CellMouseEventArgs) ' Override OnMouseDown method to customize the action. If e.Button = MouseButtons.Left Then ' Assert the cell is current cell. If Me.GcMultiRow.CurrentCell.RowIndex = e.RowIndex AndAlso Me.GcMultiRow.CurrentCell.CellIndex = e.CellIndex Then Dim beginEditSuccess As Boolean = Me.GcMultiRow.BeginEdit(False) If beginEditSuccess Then Me.EditingCellFormattedValue = Me.GetValueFromPoint(e.Location) Me._beginMouseDraging = True End If End If End If MyBase.OnMouseDown(e) End Sub Protected Overloads Overrides Sub OnMouseMove(ByVal e As CellMouseEventArgs) If Me._beginMouseDraging Then ' Drag mouse to change the EditingCellFormattedValue. Me.EditingCellFormattedValue = Me.GetValueFromPoint(e.Location) End If MyBase.OnMouseMove(e) End Sub Protected Overloads Overrides Sub OnMouseUp(ByVal e As CellMouseEventArgs) ' When mouse is up, end dragging. Me._beginMouseDraging = False MyBase.OnMouseUp(e) 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