using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
namespace WindowsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void comboBoxProvice_SelectedIndexChanged(object sender, EventArgs e)
{
comboBoxCity.Items.Clear();
string provice = Convert.ToString(comboBoxProvice.SelectedItem);
if (provice == "河南")
{
comboBoxCity.Items.Add("开封");
comboBoxCity.Items.Add("郑州");
comboBoxCity.Items.Add("新乡");
}
if (provice == "湖南")
{
comboBoxCity.Items.Add("长沙");
comboBoxCity.Items.Add("岳阳");
comboBoxCity.Items.Add("衡阳");
}
}
private void Form1_Load(object sender, EventArgs e)
{
comboBoxProvice.Items.Add("河南");
comboBoxProvice.Items.Add("湖南");
comboBoxCity.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
}
}
}
以上为自己手工敲击代码
|
|