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.

Keeping current location of a GDBG

Thread ID:

Created:

Updated:

Platform:

Replies:

40341 Jan 31,2006 08:50 PM Feb 3,2006 09:25 AM Windows Forms 5
loading
Tags: GridControl
Administrator [Syncfusion]
Asked On January 31, 2006 08:50 PM

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 06:36 AM

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 02:21 PM

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 06:28 AM

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 02:32 PM

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 09:25 AM

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.

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.

;