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.

frozen/static current row when scrolling

Thread ID:

Created:

Updated:

Platform:

Replies:

3608 Mar 30,2003 05:03 AM Apr 1,2003 07:41 AM Windows Forms 5
loading
Tags: GridControl
Patrick van der Plas
Asked On March 30, 2003 05:03 AM

Hi, Is there an efficient way (i.e. speedy and no flickering) to make the current row (CurrentCell.RowIndex) static/frozen at a specific position in the visible part of the grid? So when scrolling down it's not the current row moving down, but the rows of the grid moving up. This to make the rows directly beneath the current row visible while scrolling. A lot of my customers complain they can not see what's present directly below the current row when scrolling, so they have to keep scroll down to make the rows visible, then a bit back up to start editing cells. It would be very nice if the grid could/can support this.

Administrator [Syncfusion]
Replied On March 31, 2003 05:18 AM

Here is a try at this. It derives the GridControl and overrides OnKeyDown to scroll things there if there is an up/down arrow key is pressed. There is a little flicker on the row header, but the whole row does not seem to flicker. public class MyGridControl : GridControl { protected override void OnKeyDown(System.Windows.Forms.KeyEventArgs e) { if(e.KeyCode == Keys.Down || e.KeyCode == Keys.Up) { int inc = 0; if(e.KeyCode == Keys.Down && this.TopRowIndex > 1) { inc = -1; } else if(e.KeyCode == Keys.Up && this.ViewLayout.LastVisibleRow < this.RowCount) { inc = 1; } if(inc != 0) { this.BeginUpdate(); int cr = this.CurrentCell.RowIndex - this.TopRowIndex; int col = this.CurrentCell.ColIndex; this.CurrentCell.Deactivate(false); this.Selections.Clear(); this.TopRowIndex += inc; this.Selections.Add(GridRangeInfo.Row(this.TopRowIndex + cr)); this.EndUpdate(); //do one or the other of these lines this.CurrentCell.Activate(this.TopRowIndex + cr, 0); //this.CurrentCell.Activate(this.TopRowIndex + cr, col); } return; } base.OnKeyDown(e); } }
 

Patrick van der Plas
Replied On March 31, 2003 11:38 PM

Changed it into: if(e.KeyCode == Keys.Down || e.KeyCode == Keys.Up) { int inc = 0; if(e.KeyCode == Keys.Up && this.TopRowIndex > 1) { inc = -1; } else if(e.KeyCode == Keys.Down && this.ViewLayout.LastVisibleRow < this.RowCount) { inc = 1; } if(inc != 0) { this.BeginUpdate(); int cr = this.CurrentCell.RowIndex - this.TopRowIndex; int col = this.CurrentCell.ColIndex; this.CurrentCell.Deactivate(false); this.TopRowIndex += inc; this.EndUpdate(); //do one or the other of these lines //this.CurrentCell.Activate(this.TopRowIndex + cr, 0); this.CurrentCell.Activate(this.TopRowIndex + cr, col); } return; } But this causes a complete repaint of all individual (visible) cells (in my derived grid class), just like a pagedown, making it not very practical. I assume the normal way of (fast) scrolling involves blitting a part of the visible area up or down and only repainting a minimum of individual cells. Allthough the 'static current row' way of scrolling is more complicated, it should be possible to optimize by blitting. Can I make the grid work like that?

Administrator [Syncfusion]
Replied On April 1, 2003 06:01 AM

Patrick, you can actually leave out the Begin/EndUpdate calls. That way the display immediately after the Deactivate call so that before the grid is scrolled there are no "dirty" window areas. That way when scrolling only the new visible scroll area needs to be painted. Example: protected override void OnKeyDown(System.Windows.Forms.KeyEventArgs e) { if(e.KeyCode == Keys.Down || e.KeyCode == Keys.Up) { int inc = 0; if(e.KeyCode == Keys.Down && this.TopRowIndex > 1) { inc = -1; } else if(e.KeyCode == Keys.Up && this.ViewLayout.LastVisibleRow < this.RowCount) { inc = 1; } if(inc != 0) { int cr = this.CurrentCell.RowIndex - this.TopRowIndex; int col = this.CurrentCell.ColIndex; this.CurrentCell.Deactivate(false); this.TopRowIndex += inc; //if necessary you could also call here EndUpdate(true) to force updating new visible cells before setting current cell. this.CurrentCell.MoveTo(this.TopRowIndex + cr, col); } return; } base.OnKeyDown(e); } Stefan

Administrator [Syncfusion]
Replied On April 1, 2003 06:09 AM

You can try using GridControl.ScrollWindow to scroll things yourself.

Patrick van der Plas
Replied On April 1, 2003 07:41 AM

Now running without the BeginEndUpdate. Performance is very good. Just some minor flickering. If users start complaining about that I'll try 'ScrollWindow'ing to reduce it (or ignore them, which is more likely;-). Thx for the input!

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.

;