DataGridCell.ColumnNumber Property
.NET Framework 3.0
Gets or sets the number of a column in the System.Windows.Forms.DataGrid control.
Namespace: System.Windows.Forms
Assembly: System.Windows.Forms (in system.windows.forms.dll)
Assembly: System.Windows.Forms (in system.windows.forms.dll)
You can use the ColumnNumber value to specify a DataColumn in the DataTable associated with the System.Windows.Forms.DataGrid control.
The following example assigns the CurrentCell property of a System.Windows.Forms.DataGrid to a DataGridCell. The value stored in the DataTable is returned by specifying DataRow and DataColumn objects through the RowNumber and ColumnNumber properties.
private void PrintCell(object sender, MouseEventArgs e) { DataGrid thisGrid = (DataGrid) sender; DataGridCell myDataGridCell = thisGrid.CurrentCell; BindingManagerBase bm = BindingContext[thisGrid.DataSource, thisGrid.DataMember]; DataRowView drv = (DataRowView) bm.Current; Console.WriteLine(drv [myDataGridCell.ColumnNumber]); Console.WriteLine(myDataGridCell.RowNumber); }
private void PrintCell(Object sender, MouseEventArgs e)
{
DataGrid thisGrid = (DataGrid)(sender);
DataGridCell myDataGridCell = thisGrid.get_CurrentCell();
BindingManagerBase bm = get_BindingContext().
get_Item(thisGrid.get_DataSource(),
thisGrid.get_DataMember());
DataRowView drv = (DataRowView)(bm.get_Current());
Console.WriteLine(drv.get_Item(myDataGridCell.get_ColumnNumber()));
Console.WriteLine(myDataGridCell.get_RowNumber());
} //PrintCell
Windows 98, Windows Server 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.