This is my first post and i am new to c#. I have a bindinglist
How can i fetch the selected rows in the datagridview directly as (customObject) or list of them. I am getting a DataGridViewSelectedRowCollect
Thanks
regards,
Dewang
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Bryian TanRank #396 · 6.3K reputationPosted Aug 31, 2010, 5:27 PM EDT
You can use the DataGridViewRow.DataBoundItem Property. Try this way
private void dataGridView1_CellClick(object sender, DataGridViewCellEventArgs e)
{
DataGridViewRow theRow = dataGridView1.SelectedRows[0];
YourCustomObject yourCustomObject = theRow.DataBoundItem as YourCustomObject;
}
Thanks,
Bryian Tan