我前两天刚做的~希望你能用到~那些绑定的数据是从数据模型层取的 不用管那些 看会思想就行了
public void cboxbind()//combobox数据绑定
{
new CollegeManage().ACollegeInfo();
if (UserContext.CollegeNames == null)
{
MessageBox.Show("当前没有学院,请先添加", "提示");
this.Close();
}
else
{
for (int i = 0; i < UserContext.CollegeNames.Length; i++)
{
cboxcollege.Items.Add(UserContext.CollegeNames[i].Cname);
}
}
}
public void lboxbind()//list专业信息绑定
{
txtname.Clear();
lboxspec.Items.Clear();
new SpecManage().ASpecInfo(UserContext.SelectCollege.Cid);
for (int i = 0; i < UserContext.SpecNames.Length; i++)
{
lboxspec.Items.Add(UserContext.SpecNames[i].Sname);
}
}
private void frmSpecSet_Load(object sender, EventArgs e)
{
cboxbind();
}
private void cboxcollege_SelectedIndexChanged(object sender, EventArgs e)
{
CollegeInfo ci = new CollegeInfo();
();
ci.Cid = new CollegeManage().GetCid();
UserContext.SelectCollege = ci;
lboxbind();
}