I have the following code:
DataTable table = new DataTable(); //DataTable is filled with values here... DataGridView grid = new DataGridView(); foreach (DataColumn column in table.Columns) { grid.Columns.Add(column.ColumnName, column.ColumnName); } grid.DataSource = table;
When I examine the grid , the DataSource attribute indicates that the number of rows is correct. However, the grid.Rows counter is zero.
In contrast, if I create a DataGridView in winform and then assign it DataSource a DataTable , DataGridView.Rows is automatically added.
What code am I missing here to correctly count the DataGridView.Rows counter?
source share