public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
cbCollege.SelectedIndex = 0;
}
private void cbCollege_SelectedIndexChanged(object sender, EventArgs e)
{
cbSubject.Items.Clear();
string college = Convert.ToString(cbCollege.SelectedItem);
if (college == "商学院")
{
cbSubject.Items.Add("会计");
cbSubject.Items.Add("市场营销");
}
if (college == "信息工程学院")
{
cbSubject.Items.Add("软件技术");
cbSubject.Items.Add("动漫 ");
cbSubject.Items.Add("计算机应用 ");
}
cbSubject.SelectedIndex = 0;
}
用到的是SelectedIndexChanged事件 |