DataGridCell.RowNumber 属性
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
获取或设置 DataGrid 控件中某行的行号。
public:
property int RowNumber { int get(); void set(int value); };
public int RowNumber { get; set; }
member this.RowNumber : int with get, set
Public Property RowNumber As Integer
属性值
该行的行号。
示例
以下示例将 a 属性分配给 CurrentCell a System.Windows.Forms.DataGrid DataGridCell 并返回存储在对象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
注解
可以使用RowNumber该值指定与System.Windows.Forms.DataGrid控件关联的值DataRowDataTable。