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
我在这也问了,没解决。。 展开
{
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
我在这也问了,没解决。。 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询