MultiRow Windows Forms > Developer's Guide > Using MultiRow > Grid > Retrieving the Method Used to Move Cells |
In the GcMultiRow control, use the MoveStatus property to get the action used to move cells.
The MoveStatus property can be used in the following events.
Values that can be retrieved using the MoveStatus property are members of the MoveStatus enumeration.
If you use the SelectionActions action to move the current cell, the value corresponding to the action is retrieved. Also, if you use the mouse to move the current cell, the MoveStatus property retrieves MouseClick. If you move the current cell by some other operation, the MoveStatus property retrieves NoAction.
You need to use the CellMoveEventArgs class in order to use MoveStatus in the CellEnter, CellLeave, RowEnter, and RowLeave events.
By default, the CellEnter and CellLeave events are defined in the CellEventArgs class, to ensure compatibility. |
The following code uses the CellEnter event.
Imports GrapeCity.Win.MultiRow Private Sub GcMultiRow1_CellEnter(sender As Object, e As CellEventArgs) Handles GcMultiRow1.CellEnter Dim newArgs As CellMoveEventArgs = DirectCast(e, CellMoveEventArgs) If newArgs.MoveStatus = MoveStatus.MouseClick Then Console.WriteLine(GcMultiRow1.CurrentCellPosition) End If End Sub |
using GrapeCity.Win.MultiRow; private void gcMultiRow1_CellEnter(object sender, CellEventArgs e) { CellMoveEventArgs newArgs = e as CellMoveEventArgs; if (newArgs.MoveStatus == MoveStatus.MouseClick) { Console.WriteLine(gcMultiRow1.CurrentCellPosition); } } |
In the CellEndEdit event, use the CellEndEditEventArgs class to get the MoveStatus property. If you want to use MoveStatus in the CellEndEdit event, the current cell must be in edit mode.
In the NewCellPositionNeeded event, use the NewCellPositionNeededEventArgs class to get the MoveStatus property.
In the NewCellPositionNeeded event, you can use NewCellPosition property in combination with another operation to change the position when moving the current cell.
The following code prevents moving a cell with a mouse click.
Imports GrapeCity.Win.MultiRow Private Sub GcMultiRow1_NewCellPositionNeeded(sender As Object, e As GrapeCity.Win.MultiRow.NewCellPositionNeededEventArgs) Handles GcMultiRow1.NewCellPositionNeeded If e.MoveStatus = MoveStatus.MouseClick Then e.NewCellPosition = GcMultiRow1.CurrentCellPosition End If End Sub |
using GrapeCity.Win.MultiRow; private void gcMultiRow1_NewCellPositionNeeded(object sender, NewCellPositionNeededEventArgs e) { if (e.MoveStatus == MoveStatus.MouseClick) { e.NewCellPosition = gcMultiRow1.CurrentCellPosition; } } |