I have a class like this:
public partial class AdressBokPerson
{
public long Session { get; set; }
public string Förnamn { get; set; }
public string Efternamn { get; set; }
public string Mail { get; set; }
}
Added to a list:
private readonly List<AdressBokPerson> _avp = new List<AdressBokPerson>();
With binding to a dataGridView like this:
dataGridView1.DataSource = _avp;
So far so good.
Here is my question:
How do I find out 'which' object is selected when a row in the dataGridView is selected. I need to retrieve the selected object AdressBokPerson somehow.
You get the object by casting the DataBoundItem to the specified type:
AdressBokPerson currentObject = (AdressBokPerson)dataGridView1.CurrentRow.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