virtual grid - capturing selected row changed

i want to be able to capture an event from the grid when the user changes selected rows.

which event from the grid should i listen to capture this here ?

I tried using the selection changed event but the first time the user clicks on the grid the value or rowIndex is -1 which doesn't help much.

Again, my requirement is to simply have an event raised when a user changes rows. In the callback of that event, i would like to know the current row selected. Any ideas? Can you send me an example.

thks,
ak

1 Reply

AD Administrator Syncfusion Team November 30, 2006 05:00 AM UTC

Hi Adam,

You can handle the CurrentCellMoved event and use Selections.Ranges.AnyRangeContains() method to determine the current row selection in a grid. Here is a code snippet

private void gridControl1_CurrentCellMoved(object sender, Syncfusion.Windows.Forms.Grid.GridCurrentCellMovedEventArgs e)
{
GridControl grid = sender as GridControl;
GridCurrentCell cc = grid.CurrentCell;

if( grid.Model.Selections.Ranges.AnyRangeContains(GridRangeInfo.Row(cc.RowIndex)))
{
Console.WriteLine("CurrentRowNo: {0} Selected", cc.RowIndex );
}
}

Best Regards,
Haneef

Loader.
Up arrow icon