This documentation is archived and is not being maintained.

DataGridCell Structure

Identifies a cell in the grid.

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

public struct DataGridCell

The DataGridCell type exposes the following members.

Public methodDataGridCellInitializes a new instance of the DataGridCell class.

Public propertyColumnNumberGets or sets the number of a column in the System.Windows.Forms.DataGrid control.
Public propertyRowNumberGets or sets the number of a row in the System.Windows.Forms.DataGrid control.

Public methodEqualsGets a value indicating whether the DataGridCell is identical to a second DataGridCell. (Overrides ValueType.Equals(Object).)
Protected methodFinalizeAllows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection. (Inherited from Object.)
Public methodGetHashCodeGets a hash value that can be added to a Hashtable. (Overrides ValueType.GetHashCode().)
Public methodGetTypeGets the Type of the current instance. (Inherited from Object.)
Protected methodMemberwiseCloneCreates a shallow copy of the current Object. (Inherited from Object.)
Public methodToStringGets the row number and column number of the cell. (Overrides ValueType.ToString().)

The DataGridCell can be used in conjunction with the System.Windows.Forms.DataGrid control's CurrentCell property to get or set the value of any cell. Setting the System.Windows.Forms.DataGrid control's CurrentCell property to a DataGridCell causes the focus to move to the cell specified by the DataGridCell.

The following example assigns the DataGridCell to the CurrentCell of a System.Windows.Forms.DataGrid and returns the column and row number of the selected cell. The value stored in the DataTable is also printed using the DataGridCell object's RowNumber and ColumnNumber.

private void PrintCellRowAndCol()
   DataGridCell myCell;
   myCell = DataGrid1.CurrentCell;
   // Prints the value of the cell through the DataTable.
   DataTable myTable;
   // Assumes the DataGrid is bound to a DataTable.
   myTable = (DataTable) DataGrid1.DataSource;

.NET Framework

Supported in: 4, 3.5, 3.0, 2.0, 1.1, 1.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows XP SP2 x64 Edition, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

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

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.