DataGridCell.RowNumber 属性
获取或设置 System.Windows.Forms.DataGrid 控件中某行的行号。
**命名空间:**System.Windows.Forms
**程序集:**System.Windows.Forms(在 system.windows.forms.dll 中)
语法
声明
Public Property RowNumber As Integer
用法
Dim instance As DataGridCell
Dim value As Integer
value = instance.RowNumber
instance.RowNumber = value
public int RowNumber { get; set; }
public:
property int RowNumber {
int get ();
void set (int value);
}
/** @property */
public int get_RowNumber ()
/** @property */
public void set_RowNumber (int value)
public function get RowNumber () : int
public function set RowNumber (value : int)
属性值
该行的行号。
备注
可使用 RowNumber 值指定与 System.Windows.Forms.DataGrid 控件关联的 DataTable 中的 DataRow。
示例
下面的示例将 System.Windows.Forms.DataGrid 的 CurrentCell 属性分配给 DataGridCell,并返回存储在 DataTable 对象的 RowNumber 和 ColumnNumber 属性中的值。
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
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);
}
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.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 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
.NET Framework 并不是对每个平台的所有版本都提供支持。有关受支持版本的列表,请参见系统要求。
版本信息
.NET Framework
受以下版本支持:2.0、1.1、1.0
.NET Compact Framework
受以下版本支持:2.0、1.0