Keeping current location of a GDBG
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
SIGN IN To post a reply.
5 Replies
AD
Administrator
Syncfusion Team
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.
AD
Administrator
Syncfusion Team
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
AD
Administrator
Syncfusion Team
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.
AD
Administrator
Syncfusion Team
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,
AD
Administrator
Syncfusion Team
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.
SIGN IN To post a reply.
- 5 Replies
- 1 Participant
-
AD Administrator
- Feb 1, 2006 01:50 AM UTC
- Feb 3, 2006 02:25 PM UTC