Class GridCurrentCell
Manages the current cell for a grid. Provides methods for activating, deactivating, and moving the current cell.
Implements
Inherited Members
Namespace: Syncfusion.Windows.Forms.Grid
Assembly: Syncfusion.Grid.Windows.dll
Syntax
public class GridCurrentCell : GridSubComponent, IDisposable
Remarks
Use the CurrentCell property of the GridControlBase class to get access to the GridCurrentCell instance associated with a grid.
The GridCurrentCell class raises events in the associated grid to give you a chance to adjust the current cell's behavior at any stage.
Examples
The following example shows how you can customize the behavior of the current cell and highlight the whole row of the current cell instead of just the current cell itself:
/// Current cell will be moving from one position to another.
protected override void OnCurrentCellMoving(GridCurrentCellMovingEventArgs e)
{
e.Options |= GridSetCurrentCellOptions.BeginEndUpdate;
// Instead of GridSetCurrentCellOptions.BeginEndUpdate we could also
// sandwich the call in a Begin/EndUpdate pair ourselves ...
//BeginUpdate(BeginUpdateOptions.InvalidateAndScroll);
}
/// Completes a current cell's MoveTo operation indicating success.
protected override void OnCurrentCellMoved(GridCurrentCellMovedEventArgs e)
{
base.OnCurrentCellMoved(e);
//EndUpdate();
}
/// Completes a current cell's MoveTo operation indicating failure.
protected override void OnCurrentCellMoveFailed(GridCurrentCellMoveFailedEventArgs e)
{
base.OnCurrentCellMoveFailed(e);
//EndUpdate();
}
/// Highlight the current row.
protected override void OnPrepareViewStyleInfo(GridPrepareViewStyleInfoEventArgs e)
{
if (e.RowIndex > this.Model.Rows.HeaderCount && e.ColIndex > this.Model.Cols.HeaderCount
&& CurrentCell.HasCurrentCellAt(e.RowIndex))
{
e.Style.Interior = new BrushInfo(SystemColors.Highlight);
e.Style.TextColor = SystemColors.HighlightText;
e.Style.Font.Bold = true;
}
base.OnPrepareViewStyleInfo(e);
}
/// Refresh the whole row for the old position of the current cell when it is moved to
/// a new row or when current cell is deactivated stand-alone.
protected override void OnCurrentCellDeactivated(GridCurrentCellDeactivatedEventArgs e)
{
// Check if Deactivate is called stand-alone or called from MoveTo and row is moving.
if (!CurrentCell.IsInMoveTo || CurrentCell.MoveToRowIndex != CurrentCell.MoveFromRowIndex)
{
RefreshRange(GridRangeInfo.Row(e.RowIndex), GridRangeOptions.MergeAllSpannedCells);
}
base.OnCurrentCellDeactivated(e);
}
/// Refresh the whole row for the new current cell position when the current cell is moved
/// to a new row or when current cell is activated stand-alone (and there was no activate current cell).
protected override void OnCurrentCellActivated(EventArgs e)
{
// Check if Activate is called stand-alone or called from MoveTo and row is moving
base.OnCurrentCellActivated(e);
if (!CurrentCell.IsInMoveTo || CurrentCell.MoveToRowIndex != CurrentCell.MoveFromRowIndex
|| !CurrentCell.MoveFromActiveState)
{
RefreshRange(GridRangeInfo.Row(CurrentCell.RowIndex), GridRangeOptions.MergeAllSpannedCells);
}
}
Constructors
GridCurrentCell(GridControlBase)
Initializes the object, attaches it to a grid, and subscribes to events.
Declaration
public GridCurrentCell(GridControlBase grid)
Parameters
Type | Name | Description |
---|---|---|
GridControlBase | grid | The parent grid for this object. |
Fields
defaultUpdateFlag
Declaration
public bool defaultUpdateFlag
Field Value
Type |
---|
System.Boolean |
Properties
ActivateOnGotFocus
Gets or sets a value indicating whether the current cell should be activated when the grid gets the focus. The grid will set this property when it loses focus so that it later knows if a current cell should be activated when it gets focus again.
Declaration
public bool ActivateOnGotFocus { get; set; }
Property Value
Type |
---|
System.Boolean |
ColIndex
Gets the column index.
Declaration
public int ColIndex { get; }
Property Value
Type |
---|
System.Int32 |
ErrorMessage
Gets or sets the error message with reason why deactivation or validation of current cell failed.
Declaration
public string ErrorMessage { get; set; }
Property Value
Type |
---|
System.String |
Exception
Gets or sets the exception that causes failure of deactivation or validation of current cell.
Declaration
public Exception Exception { get; set; }
Property Value
Type |
---|
System.Exception |
ExternalMove
Gets or sets ExternalMove. Used by GridSelectCellsMouseController.
Declaration
public GridCurrentCellMoveDelegateHandler ExternalMove { get; set; }
Property Value
Type |
---|
GridCurrentCellMoveDelegateHandler |
HasControlFocus
Gets or sets a value indicating whether a System.Windows.Form.Control is displayed in the current cell and if it is focused.
Declaration
public bool HasControlFocus { get; set; }
Property Value
Type |
---|
System.Boolean |
HasCurrentCell
Gets a value indicating whether the grid has an active current cell.
Declaration
public bool HasCurrentCell { get; }
Property Value
Type |
---|
System.Boolean |
Info
Gets a string with debug information.
Declaration
public string Info { get; }
Property Value
Type |
---|
System.String |
IsActive
Gets a value indicating whether the grid has an active current cell.
Declaration
public bool IsActive { get; }
Property Value
Type |
---|
System.Boolean |
IsChanging
Gets or sets a value indicating whether the current cell's CurrentCellChanging event is being handled.
Declaration
public bool IsChanging { get; set; }
Property Value
Type |
---|
System.Boolean |
IsDroppedDown
Gets a value indicating whether the drop-down window of a current cell is dropped-down.
Declaration
public bool IsDroppedDown { get; }
Property Value
Type |
---|
System.Boolean |
IsEditing
Gets a value indicating whether the current cell is in editing mode.
Declaration
public bool IsEditing { get; }
Property Value
Type |
---|
System.Boolean |
IsError
Gets or sets the custom SetError message for validation of current cell.
Declaration
public bool IsError { get; set; }
Property Value
Type |
---|
System.Boolean |
IsInAcceptedChanges
Gets a value indicating whether IsInAcceptedChanges. Used internally.
Declaration
public bool IsInAcceptedChanges { get; }
Property Value
Type |
---|
System.Boolean |
IsInActivate
Gets a value indicating whether Activate(Int32, Int32) is in progress.
Declaration
public bool IsInActivate { get; }
Property Value
Type |
---|
System.Boolean |
Remarks
The CurrentCellActivating event gives information about the intended action and you can query RowIndex and ColIndex for the current state. HasCurrentCell will be false at the time when Activate(Int32, Int32) is called.
IsInActivated
Gets a value indicating whether IsInActivated. Used internally.
Declaration
public bool IsInActivated { get; }
Property Value
Type |
---|
System.Boolean |
IsInActiveOrDeactivate
Gets a value indicating whether Deactivate(Boolean) or Activate(Int32, Int32) is in progress.
Declaration
public bool IsInActiveOrDeactivate { get; }
Property Value
Type |
---|
System.Boolean |
IsInBeginEdit
Gets a value indicating whether true when BeginEdit() was called; False after method returned.
Declaration
public bool IsInBeginEdit { get; }
Property Value
Type |
---|
System.Boolean |
IsInConfirmChanges
Gets a value indicating whether IsInConfirmChanges. Used internally.
Declaration
public bool IsInConfirmChanges { get; }
Property Value
Type |
---|
System.Boolean |
IsInDeactivate
Gets a value indicating whether Deactivate(Boolean) is in progress.
Declaration
public bool IsInDeactivate { get; }
Property Value
Type |
---|
System.Boolean |
Remarks
The CurrentCellDeactivating event gives information about the intended action and you can query RowIndex and ColIndex for the current state. HasCurrentCell will be true at the time when Activate(Int32, Int32) is called.
IsInEndEdit
Gets a value indicating whether IsInEndEdit. Used internally.
Declaration
public bool IsInEndEdit { get; }
Property Value
Type |
---|
System.Boolean |
IsInMoveTo
Gets a value indicating whether MoveTo(Int32, Int32, GridSetCurrentCellOptions, Boolean) is in progress. MoveTo saves information about the current cell state and its target cell so that events can more easily compare previous and new states of the current cell during MoveTo(Int32, Int32, GridSetCurrentCellOptions, Boolean) calls.
Declaration
public bool IsInMoveTo { get; }
Property Value
Type |
---|
System.Boolean |
Remarks
If stand-alone Activate and Deactivate calls were made (if these calls where initiated outside from MoveTo) you can't use any of these properties. But in that case, the CurrentCellActivating and CurrentCellDeactivating events supply sufficient information about the intended action and you can query RowIndex, ColIndex, and HasCurrentCell for the current state.
IsLocked
Gets a value indicating whether the current cell's state is "locked". If the current cell is locked, any attempts to move, deactivate, save, or activate the current cell will fail.
Declaration
public bool IsLocked { get; }
Property Value
Type |
---|
System.Boolean |
IsModified
Gets or sets a value indicating whether there are pending changes in the current cell.
Declaration
public bool IsModified { get; set; }
Property Value
Type |
---|
System.Boolean |
IsSuspendEvents
Gets a value indicating whether raising events is temporarily disabled.
Declaration
public bool IsSuspendEvents { get; }
Property Value
Type |
---|
System.Boolean |
IsValid
Gets or sets a value indicating whether success of the latest Validate() method call.
Declaration
public bool IsValid { get; set; }
Property Value
Type |
---|
System.Boolean |
IsVisible
Gets a value indicating whether the current cell is shown in the current view. True if scrolled into view; False if outside current view.
Declaration
public bool IsVisible { get; }
Property Value
Type |
---|
System.Boolean |
Model
Gets the GridCellModelBase of the current cell.
Declaration
public GridCellModelBase Model { get; }
Property Value
Type |
---|
GridCellModelBase |
MoveFromActiveState
Gets a value indicating whether there was an activated current cell at the time that MoveTo(Int32, Int32, GridSetCurrentCellOptions, Boolean) was called.
Declaration
public bool MoveFromActiveState { get; }
Property Value
Type |
---|
System.Boolean |
MoveFromColIndex
Gets the saved column index information about the previous position of the current cell at the time that MoveTo(Int32, Int32, GridSetCurrentCellOptions, Boolean) was called.
Declaration
public int MoveFromColIndex { get; }
Property Value
Type |
---|
System.Int32 |
MoveFromRowIndex
Gets the saved row index information about the previous position of the current cell at the time that MoveTo(Int32, Int32, GridSetCurrentCellOptions, Boolean) was called.
Declaration
public int MoveFromRowIndex { get; }
Property Value
Type |
---|
System.Int32 |
MoveToColIndex
Gets the target column index of the current MoveTo(Int32, Int32, GridSetCurrentCellOptions, Boolean) method call.
Declaration
public int MoveToColIndex { get; }
Property Value
Type |
---|
System.Int32 |
MoveToDone
Gets a value indicating whether this will be set true when MoveTo is finishing and when CurrentCellMoved event is raise. IsInMoveTo is still true at that time, but you can check MoveToDone whether the operation has ended.
Declaration
public bool MoveToDone { get; }
Property Value
Type |
---|
System.Boolean |
MoveToOptions
Gets the GridSetCurrentCellOptions of the current MoveTo(Int32, Int32, GridSetCurrentCellOptions, Boolean) method call.
Declaration
public GridSetCurrentCellOptions MoveToOptions { get; }
Property Value
Type |
---|
GridSetCurrentCellOptions |
MoveToRowIndex
Gets the target row index of the current MoveTo(Int32, Int32, GridSetCurrentCellOptions, Boolean) method call.
Declaration
public int MoveToRowIndex { get; }
Property Value
Type |
---|
System.Int32 |
RaiseExceptionIfNestedActiveOrDeactivate
Gets or sets a value indicating whether RaiseException IfNested Active Or Deactivate. Used internally.
Declaration
public bool RaiseExceptionIfNestedActiveOrDeactivate { get; set; }
Property Value
Type |
---|
System.Boolean |
RangeInfo
Gets or sets the row and column index of the current cell as a GridRangeInfo.
Declaration
public GridRangeInfo RangeInfo { get; set; }
Property Value
Type |
---|
GridRangeInfo |
Remarks
Changing this property will trigger a call to MoveTo(Int32, Int32, GridSetCurrentCellOptions, Boolean). When the value is Empty, the current cell will be deactivated.
Exceptions
Type | Condition |
---|---|
System.ComponentModel.InvalidEnumArgumentException | if GridRangeInfo is |
Renderer
Gets the GridCellRendererBase of the current cell.
Declaration
public GridCellRendererBase Renderer { get; }
Property Value
Type |
---|
GridCellRendererBase |
RowIndex
Gets the row index.
Declaration
public int RowIndex { get; }
Property Value
Type |
---|
System.Int32 |
ShowErrorIcon
Gets or sets a value indicating whether to show or hide the error Icon in the current cell if the validation is failed.
Declaration
public bool ShowErrorIcon { get; set; }
Property Value
Type |
---|
System.Boolean |
ShowErrorMessageBox
Gets or sets a value indicating whether to show or hide the Message box with the error message.
Declaration
public bool ShowErrorMessageBox { get; set; }
Property Value
Type |
---|
System.Boolean |
StaticDrawing
Gets or sets a value indicating whether StaticDrawing. Used internally.
Declaration
public bool StaticDrawing { get; set; }
Property Value
Type |
---|
System.Boolean |
StaticRenderControl
Gets or sets StaticRenderControl. Used internally.
Declaration
public Control StaticRenderControl { get; set; }
Property Value
Type |
---|
System.Windows.Forms.Control |
ValidationErrorText
Gets or sets the custom error message to replace the default error message.
Declaration
public string ValidationErrorText { get; set; }
Property Value
Type |
---|
System.String |
Methods
Activate(Int32, Int32)
Activates the current cell at the specified position.
Declaration
public bool Activate(int rowIndex, int colIndex)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | rowIndex | The row index. |
System.Int32 | colIndex | The column index. |
Returns
Type | Description |
---|---|
System.Boolean | True if activating the current cell was successful; False otherwise. |
Remarks
Activate(Int32, Int32) raises a cancelable CurrentCellActivating event. If the event handler set the System.ComponentModel.CancelEventArgs.Cancel flag of the System.ComponentModel.CancelEventArgs object, the method will return. CurrentCellActivating gives you also the chance to modify the parameters of the Activate(Int32, Int32) function call. You can modify the row and column index and the options.
Next, it calls the cell renderer's OnActivating(Int32, Int32) before it stores internally the new row and column index and marks the cell as activated.
Then it invalidates the screen area for the specified cell and calls the cell renderer's OnInitialize(Int32, Int32) method.
At last, a CurrentCellActivated event is raised which completes this operation.
If an exception occurred or if a event handler requested to cancel the operation, Activate(Int32, Int32) will instead close up the operation with a CurrentCellActivateFailed event.
This ensures that you will get guaranteed either a CurrentCellActivated or CurrentCellActivateFailed event after a CurrentCellActivating event.
Activate(Int32, Int32, GridSetCurrentCellOptions)
Activates the current cell at the specified position.
Declaration
public bool Activate(int rowIndex, int colIndex, GridSetCurrentCellOptions options)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | rowIndex | The row index. |
System.Int32 | colIndex | The column index. |
GridSetCurrentCellOptions | options | A GridSetCurrentCellOptions value that details options how to activate the current cell. You can specify if the associated control should get focus, if range selection should be ignored and more. |
Returns
Type | Description |
---|---|
System.Boolean | True if activating the current cell was successful; False otherwise. |
AdjustRowColIfCoveredCell(ref Int32, ref Int32)
Adjusts the row index and column index if the cell belongs to a covered range. In that case, the top left cell coordinates are returned.
Declaration
public void AdjustRowColIfCoveredCell(ref int rowIndex, ref int colIndex)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | rowIndex | The row index. |
System.Int32 | colIndex | The column index. |
Examples
This example shows how to adjust the row index and column index, if it is covered.
//Adjust the row and column index if it is covered cell.
int row = this.gridControl1.CurrentCell.RowIndex;
int col = this.gridControl1.CurrentCell.ColIndex;
this.gridControl1.CurrentCell.AdjustRowColIfCoveredCell(ref row, ref col);
'Adjust the row and column if it is covered cell.
Dim row As Integer = Me.gridControl1.CurrentCell.RowIndex
Dim col As Integer = Me.gridControl1.CurrentCell.ColIndex
Me.gridControl1.CurrentCell.AdjustRowColIfCoveredCell(row, col)
BeginEdit()
Starts editing mode for the current cell.
Declaration
public bool BeginEdit()
Returns
Type | Description |
---|---|
System.Boolean | True if current cell supports editing; False otherwise. |
Remarks
You check IsEditing to query if the current cell is in editing mode.
The method calls the cell renderer's OnBeginEdit() method and thereby requests that current cell sets shows and focus to an associated System.Windows.Forms.Control. The text box cell for example, will make its TextBox visible and set the focus.
Also, the current cell will be scrolled into view.
BeginEdit(Boolean)
Starts editing mode for the current cell and allows setting the focus to the cell editor.
Declaration
public bool BeginEdit(bool focusRenderer)
Parameters
Type | Name | Description |
---|---|---|
System.Boolean | focusRenderer | Specifies if focus can be set to the cell editor. |
Returns
Type | Description |
---|---|
System.Boolean | True ifediting can proceed; False if it is aborted. |
CancelEdit()
Cancels editing for the current cell and discards any changes.
Declaration
public void CancelEdit()
Remarks
Close any open drop-down windows.
If the current cell was modified, the method calls RejectChanges() which triggers a CurrentCellRejectedChanges event.
After the cell renderer has been asked to stop editing, a CurrentCellEditingComplete event is raised.
CloseDropDown(PopupCloseType)
Closes the drop-down window.
Declaration
public void CloseDropDown(PopupCloseType reason)
Parameters
Type | Name | Description |
---|---|---|
PopupCloseType | reason | The reason lets you specify if the popup is closed because your application is being deactivated or because the user clicked in the grid and changes in the current cell should be confirmed. |
Remarks
Calls the renderer's OnCloseDropDown(PopupCloseType) method.
ConfirmChanges()
Confirms any pending changes for the current cell and closes any open drop-down windows.
Declaration
public bool ConfirmChanges()
Returns
Type | Description |
---|---|
System.Boolean | True if changes could be saved or if current cell was not modified; False if saving the changes failed. |
Remarks
If the current cell was modified, the method raises a CurrentCellValidating event and if the contents are valid the cell renderers OnSaveChanges() are called to save the changes.
After changes have been successfully confirmed to the grid, a CurrentCellAcceptedChanges event is raised.
ConfirmChanges(Boolean)
Confirms any pending changes for the current cell.
Declaration
public bool ConfirmChanges(bool closeDropDown)
Parameters
Type | Name | Description |
---|---|---|
System.Boolean | closeDropDown | Specifies where any open drop-down windows should be closed. |
Returns
Type | Description |
---|---|
System.Boolean | True if changes could be saved or if current cell was not modified; False if saving the changes failed. |
Deactivate(Boolean)
Deactivates the current cell and confirms or rejects changes made to the current cell.
Declaration
public bool Deactivate(bool discardChanges)
Parameters
Type | Name | Description |
---|---|---|
System.Boolean | discardChanges | True if changes can be discarded; False otherwise. |
Returns
Type | Description |
---|---|
System.Boolean | True if current cell can be deactivated; False otherwise. |
Remarks
Deactivate(Boolean) raises a cancelable CurrentCellDeactivating event. If the event handler set the System.ComponentModel.CancelEventArgs.Cancel flag of the System.ComponentModel.CancelEventArgs object, the method will return.
Next, it checks if the cell is modified and depending on the value of the discardChanges parameter, it tries to confirm changes by calling ConfirmChanges() or discarding changes by calling RejectChanges(). Also, any open drop-down windows will be closed at this time.
Above method calls will raise CurrentCellValidating then CurrentCellValidated and CurrentCellAcceptedChanges or CurrentCellRejectedChanges events followed by a CurrentCellEditingComplete event if the cell was in editing mode.
After the changes have been saved or canceled, the cell area is invalidated and a CurrentCellDeactivated event is raised which completes this operation.
If an exception occurred or if a event handler requested to cancel the operation, Deactivate(Boolean) will instead close the operation with a CurrentCellDeactivateFailed event.
This ensures that you will get guaranteed either a CurrentCellDeactivated or CurrentCellDeactivateFailed event after a CurrentCellDeactivating event.
When current cell has been deactivated, the HasCurrentCell property will be false indicating the grid has no active current cell at this time.
DisplayWarningText(String)
Displays the warning text.Used internally.
Declaration
public void DisplayWarningText(string message)
Parameters
Type | Name | Description |
---|---|---|
System.String | message |
Dispose(Boolean)
Disposes the unmanaged resources.
Declaration
protected override void Dispose(bool disposing)
Parameters
Type | Name | Description |
---|---|---|
System.Boolean | disposing |
Overrides
EndEdit()
Finished up editing mode for the current cell.
Declaration
public void EndEdit()
Remarks
Close any open drop-down windows.
If the current cell was modified, the method tries to confirm changes by calling ConfirmChanges(). If the changes can not be confirmed an exception is shown with ErrorMessage as exception text.
If changes are confirmed, a CurrentCellEditingComplete event is raised.
GetCurrentCell(out Int32, out Int32)
Returns position of the current cell together with a boolean if the current cell is active or not.
Declaration
public bool GetCurrentCell(out int rowIndex, out int colIndex)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | rowIndex | The row index of the current cell. |
System.Int32 | colIndex | The column index of the current cell. |
Returns
Type | Description |
---|---|
System.Boolean | True if grid has active current cell; False otherwise. |
GetCurrentCell(out Int32, out Int32, Boolean)
Returns position of the current cell together with a boolean if the current cell is active or not.
Declaration
public bool GetCurrentCell(out int rowIndex, out int colIndex, bool bIgnorePrint)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | rowIndex | The row index of the current cell. |
System.Int32 | colIndex | The column index of the current cell. |
System.Boolean | bIgnorePrint | True if current cell should also be returned when PrintingMode is True. |
Returns
Type | Description |
---|---|
System.Boolean | True if grid has active current cell; False otherwise. |
HasCurrentCellAt(Int32)
Checks if the current cell is active and at the specific row index.
Declaration
public bool HasCurrentCellAt(int rowIndex)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | rowIndex | The row index. |
Returns
Type | Description |
---|---|
System.Boolean | True if current cell was found at row index; False otherwise. |
HasCurrentCellAt(Int32, Int32)
Checks if the current cell is active and at the specific row and column index.
Declaration
public bool HasCurrentCellAt(int rowIndex, int colIndex)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | rowIndex | The row index. |
System.Int32 | colIndex | The column index. |
Returns
Type | Description |
---|---|
System.Boolean | True if current cell was found at row and column index; False otherwise. |
HasCurrentCellAt(Int32, Int32, Boolean)
Checks if the current cell is active and at the specific row and column index.
Declaration
public virtual bool HasCurrentCellAt(int rowIndex, int colIndex, bool bIgnorePrint)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | rowIndex | The row index. |
System.Int32 | colIndex | The column index. |
System.Boolean | bIgnorePrint | True if current cell should also be returned when PrintingMode is True. |
Returns
Type | Description |
---|---|
System.Boolean | True if current cell was found at row and column index; False otherwise. |
Invalidate()
Invalidates the grid window area where the current cell is positioned.
Declaration
public void Invalidate()
Lock()
Lets you temporarily "lock" the current cell. While a current cell is locked, any attempts to move, deactivate, save, or activate the current cell will fail.
Declaration
public void Lock()
Move(GridDirectionType, Int32, Boolean)
Moves the current cell in a given direction skipping a specified number of cells and optionally selecting the cells.
Declaration
public bool Move(GridDirectionType direction, int num, bool extendSelection)
Parameters
Type | Name | Description |
---|---|---|
GridDirectionType | direction | The GridDirectionType that specifies the direction of the current cell movement. |
System.Int32 | num | The number of cells to move. |
System.Boolean | extendSelection | Extends the current selection. |
Returns
Type | Description |
---|---|
System.Boolean | True if the current cell was moved to a new position; False otherwise (e.g. if current cell is at first row and you tried to move up). |
Move(GridDirectionType, Int32, Boolean, Boolean)
Moves the current cell in a given direction skipping a specified number of cells and optionally selecting the cells.
Declaration
public bool Move(GridDirectionType direction, int num, bool extendSelection, bool wrapCell)
Parameters
Type | Name | Description |
---|---|---|
GridDirectionType | direction | The GridDirectionType that specifies the direction of the current cell movement. |
System.Int32 | num | The number of cells to move. |
System.Boolean | extendSelection | Extends the current selection. |
System.Boolean | wrapCell | Indicates if grid should move to beginning of next row when at end of row or vice versa. |
Returns
Type | Description |
---|---|
System.Boolean | True if the current cell was moved to a new position; False otherwise (e.g. if current cell is at first row and you tried to move up). |
MoveDown()
Moves the current cell down to the next enabled row.
Declaration
public void MoveDown()
Remarks
See MoveTo(Int32, Int32, GridSetCurrentCellOptions, Boolean) for a discussion about the order of events that you receive when the current cell is moved.
MoveDown(Int32)
Moves the current cell down to the next enabled row after skipping a specified number of rows.
Declaration
public void MoveDown(int num)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | num | The number of rows to move. |
MoveDown(Int32, Boolean)
Moves the current cell down to the next enabled row after skipping a specified number of rows and selects the cells.
Declaration
public void MoveDown(int num, bool extendSelection)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | num | The number of rows to move. |
System.Boolean | extendSelection | Extends the current selection. |
MoveLeft()
Moves the current cell left to the next enabled column.
Declaration
public void MoveLeft()
Remarks
See MoveTo(Int32, Int32, GridSetCurrentCellOptions, Boolean) for a discussion about the order of events that you receive when the current cell is moved.
MoveLeft(Int32)
Moves the current cell left to the next enabled column after skipping a specified number of columns.
Declaration
public void MoveLeft(int num)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | num | The number of columns to move. |
MoveLeft(Int32, Boolean)
Moves the current cell left to the next enabled column after skipping a specified number of columns and selects the cells.
Declaration
public void MoveLeft(int num, bool extendSelection)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | num | The number of columns to move. |
System.Boolean | extendSelection | Extends the current selection. |
MovePageDown()
Moves the current cell down one page to the next enabled row.
Declaration
public void MovePageDown()
Remarks
See MoveTo(Int32, Int32, GridSetCurrentCellOptions, Boolean) for a discussion about the order of events that you receive when the current cell is moved.
MovePageDown(Boolean)
Moves the current cell down one page to the next enabled row.
Declaration
public void MovePageDown(bool extendSelection)
Parameters
Type | Name | Description |
---|---|---|
System.Boolean | extendSelection | Extends the current selection. |
MovePageUp()
Moves the current cell up one page to the next enabled row.
Declaration
public void MovePageUp()
Remarks
See MoveTo(Int32, Int32, GridSetCurrentCellOptions, Boolean) for a discussion about the order of events that you receive when the current cell is moved.
MovePageUp(Boolean)
Moves the current cell up one page to the next enabled row.
Declaration
public void MovePageUp(bool extendSelection)
Parameters
Type | Name | Description |
---|---|---|
System.Boolean | extendSelection | Extends the current selection. |
MoveRight()
Moves the current cell right to the next enabled column.
Declaration
public void MoveRight()
Remarks
See MoveTo(Int32, Int32, GridSetCurrentCellOptions, Boolean) for a discussion about the order of events that you receive when the current cell is moved.
MoveRight(Int32)
Moves the current cell right to the next enabled column after skipping a specified number of columns.
Declaration
public void MoveRight(int num)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | num | The number of columns to move. |
MoveRight(Int32, Boolean)
Moves the current cell right to the next enabled column after skipping a specified number of columns and selects the cells.
Declaration
public void MoveRight(int num, bool extendSelection)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | num | The number of columns to move. |
System.Boolean | extendSelection | Extends the current selection. |
MoveTo(GridRangeInfo)
Moves the current cell to the specified position.
Declaration
public bool MoveTo(GridRangeInfo range)
Parameters
Type | Name | Description |
---|---|---|
GridRangeInfo | range | A GridRangeInfo that holds new row and column index for the current cell; if it is Empty only the current cell will be deactivated. |
Returns
Type | Description |
---|---|
System.Boolean | True if the current cell could be moved; False otherwise. |
MoveTo(GridRangeInfo, GridSetCurrentCellOptions)
Moves the current cell to the specified area and gives instruction about activation of the current cell.
Declaration
public bool MoveTo(GridRangeInfo range, GridSetCurrentCellOptions options)
Parameters
Type | Name | Description |
---|---|---|
GridRangeInfo | range | A GridRangeInfo that holds new row and column index for the current cell; if it is Empty only the current cell will be deactivated. |
GridSetCurrentCellOptions | options | A GridSetCurrentCellOptions value that details options how to activate the current cell. You can specify if the associated control should get focus, if range selection should be ignored and more. |
Returns
Type | Description |
---|---|
System.Boolean | True if the current cell could be moved; False otherwise. |
MoveTo(GridRangeInfo, GridSetCurrentCellOptions, Boolean)
Moves the current cell to the specified area and gives instruction about activation of the current cell. Changes may be discarded in the previous current cell.
Declaration
public bool MoveTo(GridRangeInfo range, GridSetCurrentCellOptions options, bool discardChanges)
Parameters
Type | Name | Description |
---|---|---|
GridRangeInfo | range | A GridRangeInfo that holds new row and column index for the current cell; if it is Empty only the current cell will be deactivated. |
GridSetCurrentCellOptions | options | A GridSetCurrentCellOptions value that details options how to activate the current cell. You can specify if the associated control should get focus, if range selection should be ignored and more. |
System.Boolean | discardChanges | True if changes can be discarded; False otherwise. |
Returns
Type | Description |
---|---|
System.Boolean | True if the current cell could be moved; False otherwise. |
MoveTo(Int32, Int32)
Moves the current cell to the specified position.
Declaration
public bool MoveTo(int rowIndex, int colIndex)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | rowIndex | The row index. |
System.Int32 | colIndex | The column index. |
Returns
Type | Description |
---|---|
System.Boolean | True if the current cell could be moved; False otherwise. |
MoveTo(Int32, Int32, GridSetCurrentCellOptions)
Moves the current cell to the specified area and gives instruction about activation of the current cell.
Declaration
public bool MoveTo(int rowIndex, int colIndex, GridSetCurrentCellOptions options)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | rowIndex | The row index. |
System.Int32 | colIndex | The column index. |
GridSetCurrentCellOptions | options | A GridSetCurrentCellOptions value that details options how to activate the current cell. You can specify if the associated control should get focus, if range selection should be ignored and more. |
Returns
Type | Description |
---|---|
System.Boolean | True if the current cell could be moved; False otherwise. |
MoveTo(Int32, Int32, GridSetCurrentCellOptions, Boolean)
Moves the current cell to the specified position and gives instruction about activation of the current cell. Changes may be discarded in the previous current cell.
Declaration
public bool MoveTo(int rowIndex, int colIndex, GridSetCurrentCellOptions options, bool discardChanges)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | rowIndex | The row index. |
System.Int32 | colIndex | The column index. |
GridSetCurrentCellOptions | options | A GridSetCurrentCellOptions value that details options how to activate the current cell. You can specify if the associated control should get focus, if range selection should be ignored and more. |
System.Boolean | discardChanges | True if changes can be discarded; False otherwise. |
Returns
Type | Description |
---|---|
System.Boolean | True if the current cell could be moved; False otherwise. |
Remarks
Moving the current cell is a two step process. In the first step, the grid deactivates the existing current cell, in the second step the grid activates the new current cell.
All parameters that were specified in this method call will be saved. This allows event handler to have better background knowledge why certain events were raised.
You can determine if Deactivate(Boolean) was called stand-alone or as result of a MoveTo(Int32, Int32, GridSetCurrentCellOptions, Boolean) call by checking the IsInMoveTo property.
You can find out about the current cell's position by querying the RowIndex and ColIndex properties of the CurrentCell object in GridControlBase.
After saving parameter information MoveTo(Int32, Int32, GridSetCurrentCellOptions, Boolean) raises a cancelable CurrentCellMoving event. If the event handler set the System.ComponentModel.CancelEventArgs.Cancel flag of the GridCurrentCellMovingEventArgs object, the method will return immediately. CurrentCellMoving gives you the chance to modify the parameters of the MoveTo(Int32, Int32, GridSetCurrentCellOptions, Boolean) function call. You can modify the row and column index and the options.
The next step is to deactivate the current cell. See Deactivate(Boolean) for a detailed overview what events will get raised from Deactivate(Boolean).
After the cell has been deactivated, the current cell will be activated at the new position. See the Activate(Int32, Int32) method for information which events are raised. If the NoActivate option is specified no current cell will be activated.
You can sandwich the deactivation and activation process with a BeginUpdate, EndUpdate call pair if you specify the BeginEndUpdate option.
At last, a CurrentCellMoved event is raised which completes this operation.
If an exception occurred or if an event handler requested to cancel the operation, MoveTo(Int32, Int32, GridSetCurrentCellOptions, Boolean) will instead close up the operation with a CurrentCellMoveFailed event.
This ensures that you will be guaranteed either a CurrentCellMoved or CurrentCellMoveFailed event after a CurrentCellMoving event.
MoveUp()
Moves the current cell up to the next enabled row.
Declaration
public void MoveUp()
Remarks
See MoveTo(Int32, Int32, GridSetCurrentCellOptions, Boolean) for a discussion about the order of events that you receive when the current cell is moved.
MoveUp(Int32)
Moves the current cell up to the next enabled row after skipping a specified number of rows.
Declaration
public void MoveUp(int num)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | num | The number of rows to move. |
MoveUp(Int32, Boolean)
Moves the current cell up to the next enabled row after skipping a specified number of rows and selects the cells.
Declaration
public void MoveUp(int num, bool extendSelection)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | num | The number of rows to move. |
System.Boolean | extendSelection | Extends the current selection. |
NotifyChanged()
Used internally. Raises the Syncfusion.Windows.Forms.Grid.GridControlBase.RaiseCurrentCellChanged method.
Declaration
public void NotifyChanged()
NotifyChanging()
Used internally. Determines whether the NotifyChanging event is triggered or not.
Declaration
public bool NotifyChanging()
Returns
Type | Description |
---|---|
System.Boolean | Returns boolean value NotifyChanging |
NotifyControlDoubleClick(Control)
Used internally. Raises the Syncfusion.Windows.Forms.Grid.GridControlBase.RaiseCurrentCellControlDoubleClick(System.Windows.Forms.Control) method.
The System.Windows.Forms.Control holds the grid control.Declaration
public void NotifyControlDoubleClick(Control control)
Parameters
Type | Name | Description |
---|---|---|
System.Windows.Forms.Control | control |
NotifyControlGotFocus(Control)
Used internally. Raises the CurrentCellControlGotFocus method.
The System.Windows.Forms.Control holds the grid control.Declaration
public void NotifyControlGotFocus(Control control)
Parameters
Type | Name | Description |
---|---|---|
System.Windows.Forms.Control | control |
NotifyControlLostFocus(Control)
Used internally. Raises the Syncfusion.Windows.Forms.Grid.GridControlBase.RaiseCurrentCellControlLostFocus(System.Windows.Forms.Control) method.
The System.Windows.Forms.Control holds the grid control.Declaration
public void NotifyControlLostFocus(Control control)
Parameters
Type | Name | Description |
---|---|---|
System.Windows.Forms.Control | control |
QueryNextEnabledCell(GridDirectionType, ref Int32, ref Int32)
Determines the next enabled cell when current cell wants to move into a given direction. Cells that are not marked as enabled with Enabled will be skipped.
Declaration
public bool QueryNextEnabledCell(GridDirectionType direction, ref int rowIndex, ref int colIndex)
Parameters
Type | Name | Description |
---|---|---|
GridDirectionType | direction | The GridDirectionType that specifies the direction of the current cell movement. |
System.Int32 | rowIndex | The row index. |
System.Int32 | colIndex | The column index. |
Returns
Type | Description |
---|---|
System.Boolean | True if an enabled cell was found; False otherwise. |
Remarks
This method will not raise the QueryNextCurrentCellPosition event. Instead you can call this method from your QueryNextMoveCell event handler to find out about the next enabled cell and then decide on further criteria if the suggested cell is good.
You should call GetNextCurrentCellPosition(GridDirectionType, ref Int32, ref Int32) instead if you want the QueryNextCurrentCellPosition event to be raised.
Reactivate()
Deactivates and reactivates the current cell.
Declaration
public void Reactivate()
Refresh()
Refreshes the current cell and forces it to repaint. If the current cell is not modified, this method will deactivate and reactivate current cell.
Declaration
public void Refresh()
RejectChanges()
Discards any changes for the current cell.
Declaration
public void RejectChanges()
Remarks
Close any open drop-down windows.
Calls the cell renderer's OnRejectChanges() method and resets the IsModified flag.
After the cell renderer has been asked to discard changes, a CurrentCellRejectedChanges event is raised.
ResetCurrentCellWithoutDeactivate()
Resets internally the current cell, but does not deactivate it.
Declaration
public void ResetCurrentCellWithoutDeactivate()
Remarks
HasCurrentCell will be False.
ResetError()
Resets error information for the current cell.
Declaration
public void ResetError()
ResumeEvents()
Resumes raising events.
Declaration
public void ResumeEvents()
ScrollInView()
Scrolls the current cell into view.
Declaration
public bool ScrollInView()
Returns
Type | Description |
---|---|
System.Boolean | true if operation could be completed; false if there is no active current cell. |
ScrollInView(GridScrollCurrentCellReason)
Scrolls the current cell into view.
Declaration
public bool ScrollInView(GridScrollCurrentCellReason reason)
Parameters
Type | Name | Description |
---|---|---|
GridScrollCurrentCellReason | reason |
Returns
Type | Description |
---|---|
System.Boolean | True if operation could be completed; False if there is no active current cell. |
SetCurrentCellNoActivate(Int32, Int32)
Sets internally the new position of a current cell, but does not activate it.
Declaration
public void SetCurrentCellNoActivate(int rowIndex, int colIndex)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | rowIndex | The row index. |
System.Int32 | colIndex | The column index. |
Remarks
Sets RowIndex and ColIndex/. HasCurrentCell will be True afterwards.
SetError(String)
Get or set the error message in the current cell.
Declaration
public void SetError(string displayErrorMsg)
Parameters
Type | Name | Description |
---|---|---|
System.String | displayErrorMsg |
SetIgnoreFocus(Boolean)
This call does not have any effect. Just make sure you have CausesValidation = false. Used internally.
Declaration
[Obsolete("This call does not have any effect. Just make sure you have CausesValidation = false.")]
public void SetIgnoreFocus(bool b)
Parameters
Type | Name | Description |
---|---|---|
System.Boolean | b |
SetPositionNoActivate(Int32, Int32)
Sets internally the new position of a current cell, but does not activate it.
Declaration
public void SetPositionNoActivate(int rowIndex, int colIndex)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | rowIndex | The row index. |
System.Int32 | colIndex | The column index. |
Remarks
Sets RowIndex and ColIndex but HasCurrentCell will be False.
ShowDropDown()
Shows the drop-down window.
Declaration
public void ShowDropDown()
Remarks
Calls BeginEdit() and afterwards the renderer's OnShowDropDown() method.
SuspendEvents()
Suspends raising events.
Declaration
public void SuspendEvents()
ToggleDropDown()
Hides or shows the drop-down window.
Declaration
public void ToggleDropDown()
ToString()
Returns a string that represents the current object.
Declaration
public override string ToString()
Returns
Type | Description |
---|---|
System.String | A string that represents the current object. |
Overrides
Unlock()
Unlocks a temporarily "locked" current cell with Lock().
Declaration
public void Unlock()
Validate()
Validates the contents of the current cell. If contents are invalid or if an exception is thrown, a message is stored in ErrorMessage.
Declaration
public void Validate()
Remarks
Raises the cancelable CurrentCellValidating event and calls the renderer's OnValidate() method. If contents are valid, CurrentCellValidated will be raised afterwards.