我有以下代码:
public double[] ExtractGridData(DataGridView grid)
{
numCells = grid.SelectedCells.Count;
numberOfRows = grid.SelectedRows.Count;
numberOfColumns = grid.SelectedColumns.Count;
double[] cellsData = new double[numCells];
foreach (DataGridViewCell cell in grid.SelectedCells)
{
if (cell.Value != null)
cellsData[cell.RowIndex] = Convert.ToDouble(cell.Value);
}
MessageBox.Show(numberOfRows.ToString());
return cellsData;
}
我什至尝试使用以下代码:
Int32 selectedRowCount = grid.Rows.GetRowCount(DataGridViewElementStates.Selected);
我只得到总单元格的数量,而不是数量或选定的行或列。问题可能是什么?