Export (0) Print
Expand All
Expand Minimize

Code: Determining the Selected Cell in a Windows DataGrid Control (Visual C#)

Visual Studio .NET 2003

This example sets a reference to the selected cell of an existing DataGrid control.

Example

System.Windows.Forms.DataGridCell selectedCell = dataGrid1.CurrentCell;

Compiling the Code

This example requires:

  • A DataGrid control named dataGrid1.

Robust Programming

If the DataGrid is not bound to a data source, or if no cell is selected, then the selected cell is the cell in row 0 and column 0.

See Also

Windows Forms Example Topics | Code: Retrieving the Data from the Selected Cell in a Windows DataGrid Control | DataGrid.CurrentCell Property | DataGrid Control (Windows Forms)

Show:
© 2015 Microsoft