请教一个C# Winform的数据邦定问题
在C# Winform中 我定义了一个实体 格式如下:
public class User
{
string _UserName, _Pass;
IList <string> _Other = new List <string> ();
public string UserName
{
get { return _UserName; }
set { _UserName = value; }
}
public string Pass
{
get { return _Pass; }
set { _Pass = value; }
}
public IList <string> Other
{
get { return _Other; }
set { _Other = value; }
}
}
假设Other中有两个值 "男 " "1985-1-1 "
现在我要把它邦定到DataGridView上并添加UserName、Password、Sex、Brithday列,UserName和Password列DataPropertyName分别为UserName和Password
Sex我设置了Other[ "Sex "] 结果Sex和Brithday两列都没有显示 请问我怎么设置呢?
------解决方案--------------------=========================
看看 我的 ..我不想多说了
===
==============================================================================
private List <Gro> groceryList = new List <Gro> ();
private void frmMain_Load(object sender, EventArgs e)
{
Gro[] items = new Gro[]{
new Gro( "Yogurt ",Convert.ToDecimal(2.95)),
new Gro( "Carrots ",Convert.ToDecimal(1.55)),
new Gro( "Celery ",Convert.ToDecimal(0.99)),
new Gro( "Rice ",Convert.ToDecimal(5.39)),
new Gro( "Bread ",Convert.ToDecimal(3.95)),
new Gro( "Milk ",Convert.ToDecimal(3.95)),
new Gro( "Soda ",Convert.ToDecimal(1.99)),
new Gro( "Cheese ",Convert.ToDecimal(5.99)),
new Gro( "Paper Towels ",Convert.ToDecimal(4.55))
};
groceryList.AddRange(items);
UpdateGrid(groceryList);
}
private void UpdateGrid(List <Gro> list)
{
int c=1;
decimal total=0;
dataGridView1.Rows.Clear();