1.DataSrouce是设置数据源的一个属性,DataBindings为该控件获取数据绑定,也就是要把这个控件的属性和数据源中的那个属性进行帮定。
2. string[] strs=new string[4]{"杭州","南山路","北京","中山路"};
this.comboBox1.DataSource=strs;//直接帮定不用设置
//如果是自定义的一个类的数组
public class test
{
private string a;
public string A
{
get{return a;}
set{a=value;}
}
private string b;
public string B
{
get{return b;}
set{b=value;}
}
}
test[] tests=null;
test test1=new test();
test1.A="a1";
test1.B="b1";
test test2=new test();
test2.A="a2";
test2.B="b2";
tests=new test[2]{test1,test2};
this.comboBox1.DataSource=tests;
comboBox1.DisplayMember="A";
comboBox1.ValueMember="B";