AD
Administrator
Syncfusion Team
September 20, 2004 12:25 PM UTC
Hi Steve,
When you execute the following code
this.gridControl1.Model.Rows.FreezeRange(1,row - 1);
this.gridControl1.Model.Cols.FreezeRange(1,col - 1);
The grid will move all specified rows to the top and freeze them and also move all columns to the left and freeze them. It is by design that also the grid will scroll to the most top-left cell.
You can scroll the grid back to its scroll position if you save the TopRowIndex before you call FreezeRange and then set TopRowIndex back to its old value afterwards.
Stefan
AD
Administrator
Syncfusion Team
September 20, 2004 01:23 PM UTC
Hi Stefan,
In my example I added the following code:
int T = this.gridControl1.TopRowIndex;
this.gridControl1.Model.Rows.FreezeRange(1,row -1);
this.gridControl1.Model.Cols.FreezeRange(1,col -1);
this.gridControl1.TopRowIndex = T;
The grid does not scroll back to it''s original position. For example if I attempted to freeze at row 50, col 2, my cursor moves to the top of the grid and I''m never able to get back to row 50. Perhaps, I implemented your suggestion in correctly?
Thanks,
Steve
AD
Administrator
Syncfusion Team
September 20, 2004 01:50 PM UTC
When you frezze the grid until row 50, then the fist possible scroll position is row 51.
Any row above row 50 is frozen and therefore not scrollable and can not be made the TopRowIndex.
Try setting
this.gridControl1.TopRowIndex = Math.Max(row, T);
Stefan
AD
Administrator
Syncfusion Team
September 20, 2004 02:12 PM UTC
It appears that once you freeze the top 50 rows and the grid goes back to row 1 upon this action, there is no way to get back to row 51, via the keyboard, mouse or programmatically.
Your suggestion did not work, any other ideas on how to accomplish a freeze like Excel does?
Thanks,
Steve
AD
Administrator
Syncfusion Team
September 20, 2004 02:48 PM UTC
I thought that this is exactly the same behavior that Excel has.
When you freeze the first 50 rows you can''t scroll them. Only the rows below row 50 can be scrolled. If less than 50 rows cn be displayed then you will never be able to see row 51.
Row 1-50 will always be visible, be at the top of the grid and can''t be scrolled out of view.
What should be different? (I am feeling I am misunderstanding you ...)
Stefan
AD
Administrator
Syncfusion Team
September 20, 2004 04:27 PM UTC
In excel when you go down to row 50 and freeze panes (alt-W, F). The frozen pane (rows 1-50) does not scroll to the top. This seems to be the reverse from Syncfusion in which the you cannot scroll to the bottom.
If you cannot see all 50 rows, you will never be able to see row 1, not 51. All the rows below row 50 are scrollable.
If you have a report using the Grid that has multiple headers withing a block, this allows you to scroll down to a specific header and freeze the row so you can scroll an area of the report under a header that may be at row 50 or beyond.
I have attached a bitmap from excel that demonstrates the freezing of row 50 while scrolling 51 and beyond.
Sorry for any miscommunications.
Thanks,
Steve
excel_9226.zip
AD
Administrator
Syncfusion Team
September 20, 2004 05:50 PM UTC
Hi Steve,
thanks for the explanation. I wasn''t aware of this behavior in Excel.
Good news is that you can emulate that same behavior by hiding the first few rows and columns that were not visible at that time.
Here is some new code to try:
private void button1_Click(object sender, System.EventArgs e)
{
int row,col;
row = this.gridControl1.CurrentCell.RowIndex;
col = this.gridControl1.CurrentCell.ColIndex;
for (int r = this.gridControl1.Rows.HeaderCount+1; r < this.gridControl1.TopRowIndex; r++)
this.gridControl1.HideRows[r] = true;
for (int c = this.gridControl1.Cols.HeaderCount+1; c < this.gridControl1.LeftColIndex; c++)
this.gridControl1.HideCols[c] = true;
this.gridControl1.Model.Rows.FrozenCount = row-1;
this.gridControl1.Model.Cols.FrozenCount = col-1;
this.gridControl1.Focus();
this.gridControl1.CurrentCell.MoveTo(row,col);
}
I hope I got it right now ...
Stefan
AD
Administrator
Syncfusion Team
September 21, 2004 12:23 PM UTC
Thanks Stefan. That worked.
How do you suggest I remove the frozen pane?
The following code has some issues. The current cell scrolls to a different location and it''s slow. Perhaps a begin/end update? Can rows be unhidden without disrupting the current cell location?
Thanks Again!
this.gridControl1.Model.Rows.FrozenCount = 0;
this.gridControl1.Model.Cols.FrozenCount = 0;
for (int r = this.gridControl1.Rows.HeaderCount+1; r < this.gridControl1.TopRowIndex; r++)
this.gridControl1.HideRows[r] = false;
for (int c = this.gridControl1.Cols.HeaderCount+1; c < this.gridControl1.LeftColIndex; c++)
this.gridControl1.HideCols[c] = false;
this.gridControl1.Focus();
this.gridControl1.CurrentCell.MoveTo(row,col);
AD
Administrator
Syncfusion Team
September 21, 2004 12:45 PM UTC
Try this:
bool frozen = false;
int rowsHidden = 0;
int colsHidden = 0;
private void button1_Click(object sender, System.EventArgs e)
{
frozen = !frozen;
if (frozen)
{
int row,col;
row = this.gridControl1.CurrentCell.RowIndex;
col = this.gridControl1.CurrentCell.ColIndex;
rowsHidden = 0;
colsHidden = 0;
for (int r = this.gridControl1.Rows.HeaderCount+1; r < this.gridControl1.TopRowIndex; r++)
{
this.gridControl1.HideRows[r] = true;
rowsHidden++;
}
for (int c = this.gridControl1.Cols.HeaderCount+1; c < this.gridControl1.LeftColIndex; c++)
{
this.gridControl1.HideCols[c] = true;
colsHidden++;
}
this.gridControl1.Model.Rows.FrozenCount = row-1;
this.gridControl1.Model.Cols.FrozenCount = col-1;
//this.gridControl1.CurrentCell.ScrollInView();
this.gridControl1.Focus();
}
else
{
this.gridControl1.BeginUpdate();
this.gridControl1.Model.Rows.FrozenCount = this.gridControl1.Rows.HeaderCount;
this.gridControl1.Model.Cols.FrozenCount = this.gridControl1.Cols.HeaderCount;
for (int r = this.gridControl1.Rows.HeaderCount+1; r <= rowsHidden; r++)
this.gridControl1.HideRows[r] = false;
for (int c = this.gridControl1.Cols.HeaderCount+1; c <= colsHidden; c++)
this.gridControl1.HideCols[c] = false;
this.gridControl1.InternalSetTopRow(rowsHidden+1);
this.gridControl1.InternalSetLeftCol(colsHidden+1);
rowsHidden = 0;
colsHidden = 0;
this.gridControl1.EndUpdate(false);
this.gridControl1.Refresh();
//this.gridControl1.CurrentCell.ScrollInView();
this.gridControl1.Focus();
}
}
Stefan