1. System requirements mandate this layout. It is presenting scientific data, there is no summary view that would be suitable. In this case, the humans are specially trained to use data in this format. It is the normal format for presentation of this data.
2. The choice of row and column major could not be reversed without causing user orientation.
3. There is no code above, what I demo'd was just initializg the DataGridView. Likewise, the Refresh is not within a loop and is called only once in the above.
Notice that Excel is able to fluidly scroll the view of a large spreadsheet. Why should not DataGridView be fluid? I would prefer to use a control from theCore Library, and I sure do not want to migrate my UI to VSTO while hostig Excel. Ugh.
Here is a little sample that demo's the issue. Fill the grid, and then try scrolling it. You'll need to paint a rather large DataGridView and name it "dg", and a button to load the gridnamed "loadGrid".
Code Block
public
partial class BigGrid : Form
{
public BigGrid()
{
InitializeComponent();
}
private DataGridViewColumn getCol()
{
DataGridViewColumn dgcol = new DataGridViewColumn();
dgcol.FillWeight = 1;
DataGridViewCell dgcell = new DataGridViewTextBoxCell();
dgcol.CellTemplate = dgcell;
dgcol.Width = 15;
return dgcol;
}
private void loadGrid_Click(object sender, EventArgs e)
{
dg.ClearSelection();
dg.ReadOnly =
true;
dg.AllowUserToAddRows =
false;
dg.AllowUserToDeleteRows =
false;
dg.AllowUserToOrderColumns =
false;
dg.AllowUserToResizeColumns =
false;
dg.AllowUserToResizeRows =
false;
DataGridViewCellStyle cs = new DataGridViewCellStyle();
for (int y = 0; y < 700; y++)
{
DataGridViewColumn dgcol = getCol();
dg.Columns.Add(dgcol);
}
for (int x = 0; x < 20; x++)
{
int r = dg.Rows.Add();
DataGridViewRow dgr = dg.Rows[r];
for (int y = 0; y < 700; y++)
{
dgr.Cells[y].Value =
"X";
}
}
}
}
Is there some way I could build the grid more to more efficiently scroll?
- Is there a more efficient cell to use than a DataGridViewTextboxCell? Like a DataGridViewLabelCell (which there isn't)?
- The Grid is set ReadOnly=true, all the Allows are set false. Is there any other optimization that might cut out a bunch of overhead that is needed for edittable grids (which a read-only would therefore not need)?
- Is the DataGrid a fast scroller in this situation?