Hello,
Is there a way to scroll a row into view and have the current cell moved if the grid is not the active control.
I tried two methods so far:
1) grid.TopRowIndex = targetRowIdx;
grid.CurrentCell.MoveTo(GridRangeInfo.Row(targetRowIdx));
and
2) grid.CurrentCell.MoveTo(GridRangeInfo.Row(targetRowIdx), GridSetCurrentCellOptions.ScrollInView);
The grid scrolls to the desired position, but when the grid becomes the active control (by activating the form via click) the grid moves back to the last CurrentCell setting (MoveTo is returning true).
Any ideas?
Thanks,
JL
AD
Administrator
Syncfusion Team
August 23, 2006 06:23 AM UTC
Hi JL,
I have created the sample as per your requirement. Attached sample works fine with the TopRowIndex and MoveTo method in a Grid and let me know if you are looking something different.
Here is a sample.
http://www.syncfusion.com/Support/user/uploads/ScrollGrid_145a3fcb.zip
Regards,
Haneef
JL
James Longo
August 23, 2006 02:16 PM UTC
Hi Haneef,
Thanks for replying so quickly.
This sample works only if the grid not enabled. If you enable the grid, and add a button to set the focus to the grid, you will notice that when you perform the following sequence, the grid moves back to the previous location:
1) Click the MoveTo button
2) Click the Set Focus button
3) Click the TopRowIndex button
4) Click the Set Focus button
Regards,
JL
AD
Administrator
Syncfusion Team
August 24, 2006 06:56 AM UTC
Hi JL,
When the grid get focused, it will move one row up/down to show the currentcell for editing purpose. This is the default behaviour of the Grid. If you want to overcome the default behaviour, you need to handle the TopRowChanging and LeftColChanging event. Below is code snippet
this.grid.TopRowChanging +=new Syncfusion.Windows.Forms.Grid.GridRowColIndexChangingEventHandler(gridControl1_TopRowChanging);
this.grid.LeftColChanging +=new Syncfusion.Windows.Forms.Grid.GridRowColIndexChangingEventHandler(gridControl1_LeftColChanging);
this.grid.Focus();
this.grid.TopRowChanging -=new Syncfusion.Windows.Forms.Grid.GridRowColIndexChangingEventHandler(gridControl1_TopRowChanging);
this.grid.LeftColChanging -=new Syncfusion.Windows.Forms.Grid.GridRowColIndexChangingEventHandler(gridControl1_LeftColChanging);
Let me know if this helps.
Regards,
Haneef
AD
Administrator
Syncfusion Team
August 24, 2006 07:01 AM UTC
Hi JL,
Sorry for the inconvenience caused.
When the grid get focused, it will move one row up/down to show the currentcell for editing purpose. This is the default behaviour of the Grid. If you want to overcome the default behaviour, you need to handle the TopRowChanging and LeftColChanging event. Below is code snippet
this.grid.TopRowChanging +=new GridRowColIndexChangingEventHandler(grid_TopRowChanging);
this.grid.LeftColChanging +=new GridRowColIndexChangingEventHandler(grid_LeftColChanging);
this.grid.Focus();
this.grid.TopRowChanging -=new GridRowColIndexChangingEventHandler(grid_TopRowChanging);
this.grid.LeftColChanging -=new GridRowColIndexChangingEventHandler(grid_LeftColChanging);
private void grid_TopRowChanging(object sender, Syncfusion.Windows.Forms.Grid.GridRowColIndexChangingEventArgs e)
{ e.Cancel = true; }
private void grid_LeftColChanging(object sender, Syncfusion.Windows.Forms.Grid.GridRowColIndexChangingEventArgs e)
{ e.Cancel = true;}
Here is a modified sample.
http://www.syncfusion.com/Support/user/uploads/ScrollGrid_a1f785bb.zip
Let me know if this helps.
Regards,
Haneef
JL
James Longo
August 25, 2006 12:57 PM UTC
Not an inconvenience.
This is almost what I was looking for; now, I just need the current cell to be repositioned to the row scrolled too. If the user presses an arrow key, the grid position jumps back to the previous cell position (which the grid has set as the current cell, even though there was a successfull call to CurrentCell.MoveTo())
Thanks,
James