DataGridCell.ColumnNumber 属性
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
获取或设置 DataGrid 控件中某列的列号。
public:
property int ColumnNumber { int get(); void set(int value); };
public int ColumnNumber { get; set; }
member this.ColumnNumber : int with get, set
Public Property ColumnNumber As Integer
属性值
该列的列号。
示例
以下示例将 CurrentCell a System.Windows.Forms.DataGrid 属性赋给 a DataGridCell. 通过指定DataRow对象以及DataColumn通过RowNumber属性ColumnNumber返回存储在中DataTable的值。
void PrintCell( Object^ sender, MouseEventArgs^ /*e*/ )
{
DataGrid^ thisGrid = dynamic_cast<DataGrid^>(sender);
DataGridCell myDataGridCell = thisGrid->CurrentCell;
BindingManagerBase^ bm = BindingContext[ thisGrid->DataSource,thisGrid->DataMember ];
DataRowView^ drv = dynamic_cast<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.CurrentCell;
BindingManagerBase bm = BindingContext[thisGrid.DataSource, thisGrid.DataMember];
DataRowView drv = (DataRowView) bm.Current;
Console.WriteLine(drv [myDataGridCell.ColumnNumber]);
Console.WriteLine(myDataGridCell.RowNumber);
}
Private Sub PrintCell(sender As Object, e As MouseEventArgs)
Dim thisGrid As DataGrid = CType(sender, DataGrid)
Dim myDataGridCell As DataGridCell = thisGrid.CurrentCell
Dim bm As BindingManagerBase = _
BindingContext (thisGrid.DataSource, thisGrid.DataMember)
Dim drv As DataRowView = CType(bm.Current, DataRowView)
Console.WriteLine(drv(myDataGridCell.ColumnNumber))
Console.WriteLine(myDataGridCell.RowNumber)
End Sub
注解
可以使用ColumnNumber该值指定与System.Windows.Forms.DataGrid控件关联的值DataColumnDataTable。