Export (0) Print
Expand All
Expand Minimize

DataGridView.SetCurrentCellAddressCore Method

Sets the currently active cell.

Namespace:  System.Windows.Forms
Assembly:  System.Windows.Forms (in System.Windows.Forms.dll)

'Declaration
Protected Overridable Function SetCurrentCellAddressCore ( _
	columnIndex As Integer, _
	rowIndex As Integer, _
	setAnchorCellAddress As Boolean, _
	validateCurrentCell As Boolean, _
	throughMouseClick As Boolean _
) As Boolean

Parameters

columnIndex
Type: System.Int32

The index of the column containing the cell.

rowIndex
Type: System.Int32

The index of the row containing the cell.

setAnchorCellAddress
Type: System.Boolean

true to make the new current cell the anchor cell for a subsequent multicell selection using the SHIFT key; otherwise, false.

validateCurrentCell
Type: System.Boolean

true to validate the value in the old current cell and cancel the change if validation fails; otherwise, false.

throughMouseClick
Type: System.Boolean

true if the current cell is being set as a result of a mouse click; otherwise, false.

Return Value

Type: System.Boolean
true if the current cell was successfully set; otherwise, false.

ExceptionCondition
ArgumentOutOfRangeException

columnIndex is less than 0 or greater than the number of columns in the control minus 1, and rowIndex is not -1.

-or-

rowIndex is less than 0 or greater than the number of rows in the control minus 1, and columnIndex is not -1.

InvalidOperationException

The specified cell has a Visible property value of false.

-or-

This method was called for a reason other than the underlying data source being reset, and another thread is currently executing this method.

InvalidCastException

The new current cell tried to enter edit mode, but its EditType property does not indicate a class that derives from Control and implements IDataGridViewEditingControl.

The DataGridView control uses this method whenever it changes the current cell. This method changes the current cell without changing the selection and optionally without validating the previous cell or changing the selection anchor cell. The anchor cell is the first cell of a block of multiple cells that the user can select by holding down the SHIFT key and clicking the last cell of the block.

If rowIndex and columnIndex are both -1, the CurrentCell property returns Nothing.

.NET Framework

Supported in: 4.5.2, 4.5.1, 4.5, 4, 3.5, 3.0, 2.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

Show:
© 2014 Microsoft