We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy.
Unfortunately, activation email could not send to your email. Please try again.

Freeze Question

Thread ID:

Created:

Updated:

Platform:

Replies:

19149 Sep 20,2004 06:49 AM Sep 21,2004 08:45 AM Windows Forms 9
loading
Tags: GridControl
Steve
Asked On September 20, 2004 06:49 AM

When freezing a row and column location, the grid scrolls back to the top. To demonstrate, run the program in the attached example and put focus on cell B50. Press the Freeze button and the grid scrolls to the top losing the current cell location of B50. frmFreezeRowsCols_9792.zip Thanks, Steve

Administrator [Syncfusion]
Replied On September 20, 2004 08:25 AM

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

Administrator [Syncfusion]
Replied On September 20, 2004 09:23 AM

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

Administrator [Syncfusion]
Replied On September 20, 2004 09:50 AM

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

Administrator [Syncfusion]
Replied On September 20, 2004 10:12 AM

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

Administrator [Syncfusion]
Replied On September 20, 2004 10:48 AM

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

Administrator [Syncfusion]
Replied On September 20, 2004 12:27 PM

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

Administrator [Syncfusion]
Replied On September 20, 2004 01:50 PM

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

Administrator [Syncfusion]
Replied On September 21, 2004 08:23 AM

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);

Administrator [Syncfusion]
Replied On September 21, 2004 08:45 AM

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

CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.

;