写了一个简单的省市级联,但是怎么让他默认选中第一项?using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;namespace Test3_1
{
public partial class FirstForm : Form
{
public FirstForm()
{
InitializeComponent();
} private void cmbProvince_SelectionChangeCommitted(object sender, EventArgs e)
{
object[] jiangsu = {"苏州","无锡","常州"};
object[] zhejiang = { "杭州", "温州", "绍兴"};
object[] shandong = { "济南", "青岛"}; string strPro = this.cmbProvince.Text.Trim();
//MessageBox.Show(strPro); switch (strPro)
{
case "江苏":
this.cmbCity.Items.Clear();
this.cmbCity.Items.AddRange(jiangsu);
break;
case "浙江":
this.cmbCity.Items.Clear();
this.cmbCity.Items.AddRange(zhejiang);
break;
case "山东":
this.cmbCity.Items.Clear();
this.cmbCity.Items.AddRange(shandong);
break;
} }
}
}
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;namespace Test3_1
{
public partial class FirstForm : Form
{
public FirstForm()
{
InitializeComponent();
} private void cmbProvince_SelectionChangeCommitted(object sender, EventArgs e)
{
object[] jiangsu = {"苏州","无锡","常州"};
object[] zhejiang = { "杭州", "温州", "绍兴"};
object[] shandong = { "济南", "青岛"}; string strPro = this.cmbProvince.Text.Trim();
//MessageBox.Show(strPro); switch (strPro)
{
case "江苏":
this.cmbCity.Items.Clear();
this.cmbCity.Items.AddRange(jiangsu);
break;
case "浙江":
this.cmbCity.Items.Clear();
this.cmbCity.Items.AddRange(zhejiang);
break;
case "山东":
this.cmbCity.Items.Clear();
this.cmbCity.Items.AddRange(shandong);
break;
} }
}
}
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货