How would I access the bound item for a specific row for a DataGridView bound to a Custom Collection?
The DataGridView control supports the standard Windows Forms data binding model, so it can bind to a variety of data sources. Usually, you bind to a BindingSource that manages the interaction with the data source.
The DataGrid control is limited to displaying data from an external data source. The DataGridView control, however, can display unbound data stored in the control, data from a bound data source, or bound and unbound data together.
MSDN: DataGridViewRow DataBoundItem Property
The DataBoundItem property of the DataGridViewRow seems to do the trick!
var product = (Product) _grid.SelectedRows[0].DataBoundItem;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With