for (int i = 2012; i < 2050; i++)
{
cbmYear.Items.Add(i.ToString());
}
cbmYear.Items.Insert(0, "请选择年份");
for (int i = 1; i <= 12; i++)
{
cbmMonth.Items.Add(i.ToString());
}
cbmMonth.Items.Insert(0, "请选择月份");
cbmYear.Text = DateTime.Now.Year.ToString();
cbmMonth.Text = DateTime.Now.Month.ToString();
cbmDay.Text = DateTime.Now.Day.ToString();
--在cbmMonth的OnSelectedChanged事件中:
for (int i = 1; i <= DateTime.DaysInMonth(
Convert.ToInt16(cbmYear.Text), Convert.ToInt16(cbmMonth.Text)); i++)
{
cbmDay.Items.Add(i.ToString());
}
cbmDay.Items.Insert(0, "请选择日期");