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.

Scroll a row into view while the grid is not the active control

Thread ID:

Created:

Updated:

Platform:

Replies:

48216 Aug 22,2006 01:45 PM Aug 25,2006 08:57 AM Windows Forms 5
loading
Tags: GridControl
James Longo
Asked On August 22, 2006 01:45 PM

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

Administrator [Syncfusion]
Replied On August 23, 2006 02:23 AM

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


James Longo
Replied On August 23, 2006 10:16 AM

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

Administrator [Syncfusion]
Replied On August 24, 2006 02:56 AM

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

Administrator [Syncfusion]
Replied On August 24, 2006 03:01 AM

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

James Longo
Replied On August 25, 2006 08:57 AM

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

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.

;