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. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Keeping current location of a GDBG

Thread ID:





40341 Feb 1,2006 01:50 AM UTC Feb 3,2006 02:25 PM UTC WinForms 5
Tags: GridControl
Administrator [Syncfusion]
Asked On February 1, 2006 01:50 AM UTC

Hi, How can I keep the current position of scroll bars even if I refresh (reassign the data source) the grid? Basically users want to be at the same Cell/position (cell should have the focus) after the save. I am using GDBG. Please help. VS

Administrator [Syncfusion]
Replied On February 1, 2006 11:36 AM UTC

Hi VS, One way of achieving this, is by using the MoveTo method. You can save the Row and Column index of the CurrentCell before the change in the DataSource and retain the focus using them after the change. Here is the Code snippet. GridCurrentCell cc = this.gridDataBoundGrid1.CurrentCell; int row = cc.RowIndex; int col = cc.ColIndex; this.gridDataBoundGrid1.DataSource = GetDataTable(); this.gridDataBoundGrid1.Focus(); cc.MoveTo(row,col,GridSetCurrentCellOptions.ScrollInView); Let us know if you need any further assistance. Regards, Madhan.

Administrator [Syncfusion]
Replied On February 1, 2006 07:21 PM UTC

Thanks Madhan, You code helped me but I have to use the following too. // begin update int hScrollPos = this.grid.HScrollBar.Value; int vScrollPos = this.grid.VScrollBar.Value; // update //end update GridCurrentCell cc = this.grid.CurrentCell; this.grid.Focus(); cc.MoveTo(rowIndex,colIndex,GridSetCurrentCellOptions.ScrollInView); this.grid.HScrollBar.Value = hScrollPos; this.grid.VScrollBar.Value = vScrollPos; PROBLEM: Now there is lots of flickering before the Old/actual CELL is selected again. How can I avoid it? FYI: During the update I open a dialog box and perform some data update which in turns changes my data in grid. So when I close the dialog, I need to refresh the grid with new data and the old CELL selected. Thanks, VS

Administrator [Syncfusion]
Replied On February 2, 2006 11:28 AM UTC

Hi VS, Please try this code snippet. And let us know if it helps GridCurrentCell cc = this.gridDataBoundGrid1.CurrentCell; int row = cc.RowIndex; int col = cc.ColIndex; this.gridDataBoundGrid1.BeginUpdate(); // this.gridDataBoundGrid1.BeginInit( ) this.gridDataBoundGrid1.DataSource = GetDataTable(); this.gridDataBoundGrid1.EndUpdate(); // this.gridDataBoundGrid1.EndInit( ) cc.MoveTo(row,col,GridSetCurrentCellOptions.ScrollInView); this.gridDataBoundGrid1.Focus(); Regards, Madhan.

Administrator [Syncfusion]
Replied On February 2, 2006 07:32 PM UTC

I tried your suggestion but it didn''t make any difference. Please provide any other suggestion. Can be freez the grid? Thanks,

Administrator [Syncfusion]
Replied On February 3, 2006 02:25 PM UTC

Hi VS, Try changing the ShowCurrentCellBorderBehavior with the BeginUpdate / EndUpdate to reduce the flickering. The black triangle movement can be avoided by using the FreezePainting property in a derived grid. Refer this sample for details. Kindly attach us a sample or modify the attached sample illustrating your problem, if it doesn''t helps. Regards, Madhan.


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