Gets or sets the number of a column in the DataGrid control.
[Visual Basic] Public Property ColumnNumber As Integer [C#] public int ColumnNumber {get; set;} [C++] public: __property int get_ColumnNumber(); public: __property void set_ColumnNumber(int); [JScript] public function get ColumnNumber() : int; public function set ColumnNumber(int);
The number of the column.
The ColumnNumber value can be used to specify a DataColumn object in the DataTable associated with the DataGrid control.
The following example assigns the CurrentCell property of a DataGrid to a DataGridCell. The value stored in the DataTable is returned by specifying DataRow and DataColumn objects through the RowNumber and ColumnNumber properties.
[Visual Basic]
Private Sub PrintCell() Dim myCell As DataGridCell ' Set the variable to the selected cell. myCell = DataGrid1.CurrentCell ' Get the value of the selected cell through the DataTable. Dim t As DataTable t = DataGrid1.CurrentGridTable.DataTable Console.WriteLine(t.Rows(myCell.RowNumber)(myCell.ColumnNumber)) End Sub
DataGridCell Structure | DataGridCell Members | System.WinForms Namespace | CurrentCell | DataColumn | DataRow | RowNumber