在检索选择的dataGridView行作为对象 [英] Retrieving selected row in dataGridView as an object
本文介绍了在检索选择的dataGridView行作为对象的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有这样一个类:
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>();
像这样绑定到一个DataGridView:
With binding to a dataGridView like this:
dataGridView1.DataSource = _avp;
到目前为止好。
So far so good.
< STRONG>这里是我的问题:
我如何找出'的'对象当选择在DataGridView一行被选中。我需要检索的选择对象的 AdressBokPerson 不知何故。
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.
推荐答案
您
AdressBokPerson currentObject = (AdressBokPerson)dataGridView1.CurrentRow.DataBoundItem;
这篇关于在检索选择的dataGridView行作为对象的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文