Home Forums WinForms controls Xceed Grid for WinForms CurrentRow Reply To: CurrentRow

User (Old forums)
Post count: 23064

You can use the DataRows collection to obtain this information :

in Form_Load :

foreach( Cell cell in dataRowTemplate1.Cells )
cell.Click += new EventHandler(cell_Click);

Event handler :

private void cell_Click(object sender, EventArgs e)
Xceed.Grid.DataRow row = gridControl1.CurrentRow as Xceed.Grid.DataRow;
if( row != null)
int index = gridControl1.DataRows.IndexOf( row );

Depending of the event to which you have subscribed, you may need to do the preceding safe type cast, because the CurrentRow could be something other then a DataRow. In this event however, this could all be omitted and have only the int index line, for CurrentRow is always a DataRow :

int index = gridControl1.DataRows.IndexOf( ( Xceed.Grid.DataRow )gridControl1.CurrentRow );

Imported from legacy forums. Posted by André (had 3051 views)