winform windows ce 中 怎么获取DataGrid的行数

在 winform windows ce 中 怎么获取DataGrid的行数

DataGrid.Rows.Count 不行?

直接获取数据源的数据数量
Adodc1.Recordset.Recordcount

下面的代码示例输出位于指定行和索引处的单元格所包含的值。
private void PrintCellValues(DataGrid myGrid){
int iRow;
int iCol;
DataTable myTable;
// Assumes the DataGrid is bound to a DataTable.
myTable = (DataTable) dataGrid1.DataSource;
for(iRow = 0;iRow < myTable.Rows.Count ;iRow++) {
for(iCol = 0;iCol < myTable.Columns.Count ;iCol++) {
Console.WriteLine(myGrid[iRow, iCol]);
}
}
}

DATAGRID的数据源是什么,获取数据源的时候count不行吗,获取一条count++

datagri差评,用rep