views:

159

answers:

1

Hi,

I need to get the currently selected object from da databound DataGridView.

I do not need the object of the current selected cell, but the object on which the whole row is based, in this case a BusinessObject whos properties make the columns of the grid.

I could go over the DataSource, but that itself is just an object and can be a BindingSource or a IBindingList or something like that - so not easy standartized way to get the wanted object.

Behind that is the need to just check the businessObject for a property called IsChanged and ask the user to save or discard the changes, before the bindingsource selects the next item. Therefore I must find out the current object inside RowValidating-Event of the DataGridView, since the BindingSource does not offer an event to stop changing before change occurs.See here for the well known problem

Thanks for reading ;-)

+2  A: 

DataGridViewRow.DataBoundItem contains the 'business' object it is bound to.

leppie
Thank you for hinting me correctly, sometimes one should just lay back and relax instead of searching more intensly...
BeowulfOF