Grid Row Navigation

Hi,

I am using GridDataControl as a popup (showing the matches for the criteria entered in a Textbox). I want to handle UP, DOWN, PAGEUP, AGEDOWN, HOME and END keys in the grid. Since these key input events are part of Textbox, I have a public method that handles this:

public bool HandleKey( Key key, ModifierKeys modifiers )
{
switch (key)
{
case Key.Up:
{
ICollectionViewAdv collectionViewAdv = resultsGrid.Model.View;
if (collectionViewAdv.CurrentPosition > 0) collectionViewAdv.MoveCurrentToPrevious();
break;
}
case Key.Down:
{
ICollectionViewAdv collectionViewAdv = resultsGrid.Model.View;
if (collectionViewAdv.CurrentPosition < collectionViewAdv.Records.Count - 1)
{
collectionViewAdv.MoveCurrentToNext();
}
break;
}
case Key.Home:
{
resultsGrid.Model.View.MoveCurrentToFirst();
break;
}
case Key.End:
{
resultsGrid.Model.View.MoveCurrentToLast();
break;
}
case Key.Enter:
onSelectRow();
break;
default:
return false;
}
return true;
}

I don't know how to handle PAGEUP and PAGEDOWN.
Is this the right way of doing? Can you tell me how to handle PAGEUP and PAGEDOWN?
Please let me know if you have any quetions. Thanks.

Regards
Kiran

1 Reply

MN Muthulakshmi N Syncfusion Team July 14, 2010 01:01 PM UTC

Hi Kiran,

You can handle the Page Up and PageDown for GridData Control as follows.

case Key.PageUp:
{
this.dataGrid.Model.CurrencyManager.CurrentCell.PageUp();
this.dataGrid.Model.CurrencyManager.CurrentCell.ScrollInView();
e.Handled = true;
break;
}
case Key.PageDown:
{
this.dataGrid.Model.CurrencyManager.CurrentCell.PageDown();
this.dataGrid.Model.CurrencyManager.CurrentCell.ScrollInView();
e.Handled = true;
break;
}

Please let us know if you need any more information.

Thanks,
Muthulakshmi

Loader.
Up arrow icon