我真的不能告诉你想你怎么了包括例如做,而是结合对象的泛型列表是,如果你非常简单只是要列出的对象:
private BindingSource _gridSource;
private BindingSource GridSource
{
get
{
if (_gridSource == null)
_gridSource = new BindingSource();
return _gridSource;
}
}
private void Form1_Load(object sender, EventArgs e)
{
List<FluffyBunny> list = new List<FluffyBunny>();
list.Add(new FluffyBunny { Color = "White", EarType = "Long", Name = "Stan" });
list.Add(new FluffyBunny { Color = "Brown", EarType = "Medium", Name = "Mike" });
list.Add(new FluffyBunny { Color = "Mottled", EarType = "Short", Name = "Torvald" });
GridSource.DataSource = list;
dataGridView1.Columns["EarType"].Visible = false; //Optionally hide a column
dataGridView1.DataSource = GridSource;
}
如果你只是想显示List的类型的特定属性,你应该能够使不必要的列(S)隐形。
从技术上讲,你并不需要创建BindingSource,但是如果我有更新或更改,我发现它更容易一些。
希望这会有所帮助。
LOL这正是我在我的意见又增加了,很高兴你有你的问题解决了。 – 2008-09-24 03:15:11
+1我刚刚有同样的问题。男人,吮球! – 2009-12-10 23:53:27
你是天赐之物。我已经连续六个小时一直在对付这个问题的头脑。尝试了我能想到的一切,以及我能想到的一切。没有运气。最后找到你的帖子,当然,我很匆忙,并把他们的领域,而不是属性。 – Locke 2016-10-08 02:19:29