winform中comobox 的selectedvalue不显示问题

publicXjzt(){InitializeComponent();BindYear();//BindMonth();//BindDay();}protectedvoi... public Xjzt()
{
InitializeComponent();
BindYear();
//BindMonth();
//BindDay();

}

protected void BindYear()
{
comboBox3.Items.Clear();
//int startYear = DateTime.Now.Year - 10;
//int currentYear = DateTime.Now.Year;
int startYear = Convert.ToInt32(DateTime.Now.Year)-10;
int currentYear = Convert.ToInt32(DateTime.Now.Year);

for (int i = startYear; i <= currentYear+10; i++)
{
comboBox3.Items.Add(i.ToString());
}
comboBox3.SelectedIndex = 10;
//comboBox3.SelectedItem = currentYear;
//comboBox3.Text = currentYear.ToString();
}
protected void BindMonth()
{

comboBox4.Items.Clear();
int currentMonth = Convert.ToInt32(DateTime.Now.Month);
for (int i = 1; i <= 12; i++)
{
comboBox4.Items.Add(i.ToString());
}

comboBox4.SelectedIndex =1;
//comboBox4.SelectedItem = currentMonth;
//comboBox4.Text = currentMonth.ToString();
}

protected void BindDay()
{
comboBox5.Items.Clear();
//string year = comboBox3.Text;
//string month = comboBox4.Text ;
string year = comboBox3.SelectedItem.ToString();
string month = comboBox4.SelectedItem.ToString();
int days = DateTime.DaysInMonth(int.Parse(year), int.Parse(month));
for (int i = 1; i <= days; i++)
{
comboBox5.Items.Add(i.ToString());
}
}
private void comboBox3_SelectedIndexChanged(object sender, EventArgs e)
{
BindDay();
}

private void comboBox4_SelectedIndexChanged(object sender, EventArgs e)
{
BindDay();
}

大家帮忙调试一下,总是出错、。、
http://zhidao.baidu.com/question/251336816.html
我在这也问了,没解决。。
展开
 我来答
370826chen
2011-04-11 · TA获得超过152个赞
知道答主
回答量:344
采纳率:0%
帮助的人:140万
展开全部
你光说报错,报什么错?

把你的comboBox3_SelectedIndexChanged的事件换成这个就好了
或者
就在事件里添加一个BindMonth();
在你的BindDay
之前
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式