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. Image for the cookie policy date
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

How to improve repaint performance when inserting row in virtual grid (

Thread ID:





16794 Jul 23,2004 02:20 PM UTC Jul 29,2004 11:47 AM UTC WinForms 6
Tags: GridControl
Asked On July 23, 2004 02:20 PM UTC

To implement inserting a row in the virtual grid mode I first insert the row in the data source and then repaint the grid. Say, my inserted row index is 5. It seems I need to call grid.InvalidateRange( GridRangeInfo.Rows( 5, grid.ViewLayout.VisibleCellsRange.Bottom + 1 ) ) to show the new row as well as shift ''old'' rows down. The grid is sending query cell info for all the rows in that range. Calling RefreshRange seems to do the same thing. This may affect performance in the case the grid is being dynamically updated at a high rate. It seems what the grid really needs to do is just to repaint the ''old'' rows one row down say, using a double buffered image. Is there a way to optimize the above sample?

Administrator [Syncfusion]
Replied On July 23, 2004 02:50 PM UTC

Instead of repainting from the row down to the bottom of the grid, you can use WindowScroll to scroll the display down a row from that insertion point. Then you can just repaint the single row. The grid has a property that does this when you use calls to grid.Cols.InsertRange to insert the row. You set grid.OptimizeInsertRemoveCells = true; to enable this behavior. But the problem is that you cannot use InsertRange in a viretual grid. But if you set this property, you can trigger the same events by explicilty calling grid.Rows.OnRangeInserted. You have to create the event arg to reflect the rows you are inserting. Alternatively, if you want to directly do the WindowScroll, here is a button handler that will insert a new row at row 1, and then WindowScroll every thing else below it. You could modify this code to handle an arbitrary row position being inserted.
private int counter = 0;
private void button1_Click(object sender, System.EventArgs e)
	Console.WriteLine("ClickStart " + counter.ToString());
	int heightToScroll = this.gridControl1.RowHeights[1];
	Rectangle scrollRect =  this.gridControl1.ViewLayout.RectangleBottomOfRow(

	//insert the row...
	this.data.Insert(0, NewRow());
	//scroll the window
	this.gridControl1.ScrollWindow(0, heightToScroll, scrollRect, scrollRect, true);
	//refresh the new row...

this.gridControl1.RefreshRange(GridRangeInfo.Row(1), GridRangeOptions.None);
	//refresh the col headers... (if needed) normally these would not be processed by your QCI
	this.gridControl1.RefreshRange(GridRangeInfo.Col(0), GridRangeOptions.None);
	Console.WriteLine("ClickEnd " + (counter++).ToString());

Administrator [Syncfusion]
Replied On July 26, 2004 04:04 AM UTC

Clay, thanks I used the OnRangeInserted - works fine. But the problem is the scrollable view/vertical scroll bar do not seem to update; after inserting a few rows I cannot scroll all the way to view last rows. Is there a cure to this?

Administrator [Syncfusion]
Replied On July 26, 2004 04:39 AM UTC

Try calling grid.UpdateScrollBars.

Administrator [Syncfusion]
Replied On July 26, 2004 11:10 AM UTC

I had. It did not help.

Administrator [Syncfusion]
Replied On July 26, 2004 12:09 PM UTC

Also try calling grid.ResetVolatileData. grid.Refresh calls these methods to handle things in addition to teh baseclass call that triggers the actual painting of the control. So, if grid.Refresh works, you could add these calls one at the time to see what is missing in your case. Model.ResetVolatileData(); ViewLayout.Reset(); CurrentCell.Refresh(); UpdateScrollBars();

Replied On July 29, 2004 11:47 AM UTC

CAlling ViewLayout.Reset(); did it. Thanks


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.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon 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.Close Icon

Live Chat Icon For mobile
Live Chat Icon