Archive for the ‘DevExpress’ Category

h1

Getting object from GridControl

March 26, 2008

I have binded collection of entities in the GridView. This Grid control is composed from N GridViews. Question is, how to get selected entity from this grid view??

public static Flight GetSelectedFlight(GridControl gridControl) 
{ 
   int rowHandle = ((GridView)gridControl.MainView).FocusedRowHandle; 
   if (rowHandle < 0) return Factories.Flights.CreateEmptyFlight; 
   Flight flight = gridControl.FocusedView.GetRow(rowHandle) as Flight; 
   return flight; 
}
  • GridControl.MainView method is actual used View of GridControl.
  • RowHandle < 0 means: there is not selected value
Follow

Get every new post delivered to your Inbox.