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.
Syncfusion Feedback

Question on traversing in a grid.

Thread ID:

Created:

Updated:

Platform:

Replies:

60609 May 9,2007 02:04 AM May 14,2007 05:37 PM Windows Forms 5
loading
Tags: GridControl
kesav
Asked On May 9, 2007 02:04 AM

Hi,

I have a grid containing some static fields as well as some editable fields. My requirement is when I place cursor in any one of cell and press 'Enter' key control should transfer to next editable cell, similarly when I place control on last cell of a row and press 'Enter' key control should be in first editable cell of next row. How can I achieve it?


Thanks
-Kesav

haneefm [Syncfusion]
Replied On May 9, 2007 11:03 AM

Hi Kesav,

By setting the WrapCellBehavior property to WrapRow, you can make the currentcell move to the first column of the next row when the currentcell is in last column. Below is a code snippet

this.grid.Model.Options.WrapCellBehavior = GridWrapCellBehavior.WrapRow;

Best Regards,
Haneef

kesav
Replied On May 10, 2007 01:18 AM

Hi Haneef,

The code snippet sent by you working fine to move control to the next row. But our requirement is, when 'Enter' key is pressed the control should move to the first 'editable' cell in the next row. Currently the control is moving to the first cell of next row irrespective of its celltype.

Similarly if the control is placed in a cell(not in the last cell of a row) when 'Enter' key is pressed control should move to next 'editable' cell. How can I achieve it?

Thanks
-Kesav



haneefm [Syncfusion]
Replied On May 10, 2007 03:57 PM

Hi Kesav,

This behavior is by design. But you can change it by handling the QueryNextCurrentCellPosition. Here is a code snippet that shows you "How to navigate only editable cells in a Grid?".

private void gridControl1_QueryNextCurrentCellPosition(object sender, GridQueryNextCurrentCellPositionEventArgs e)
{
if( e.Direction == GridDirectionType.Right )
{
GridControl grid = sender as GridControl;
GridCurrentCell cc = grid.CurrentCell;
e.Handled = grid.Model[e.RowIndex,e.ColIndex].ReadOnly;
if( e.Handled )
{
cc.MoveTo(e.RowIndex,e.ColIndex + 1);
cc.ScrollInView();
}
}
}

Best regards,
Haneef

kesav
Replied On May 12, 2007 01:55 AM

Hi Haneef,

The code snippet sent by you works fine to traverse through the grid when 'Enter' is clicked. But it also changed the 'Tab' button behaviour. When 'Tab' button is clicked I want the same old behaviour which traverse through each and every cell (including static cells). How can I achieve it?


Thanks
-Kesav

haneefm [Syncfusion]
Replied On May 14, 2007 05:37 PM

Hi kesav,

You can get the Enter key using the CurrentCellKeyDown event and then check that Enter key in a QueryNextCurrentCellPosition event for keeping the Tab Key behavior in a Grid. Below is a code snippet that show this.

private bool IsEnterKeyPressed = true;
private void gridControl1_CurrentCellKeyDown(object sender, KeyEventArgs e)
{
if( e.KeyData == Keys.Enter )
IsEnterKeyPressed = true;
else
IsEnterKeyPressed = false;
}

private void gridControl1_QueryNextCurrentCellPosition(object sender, GridQueryNextCurrentCellPositionEventArgs e)
{
if( IsEnterKeyPressed && e.Direction == GridDirectionType.Right )
{
GridControl grid = sender as GridControl;
GridCurrentCell cc = grid.CurrentCell;
e.Handled = grid.Model[e.RowIndex,e.ColIndex].ReadOnly;
if( e.Handled )
{
cc.MoveTo(e.RowIndex,e.ColIndex + 1);
cc.ScrollInView();
}
}
}

Best regards,
Haneef

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.

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

;