private void Form1_Load(object sender, EventArgs e)
{
//开始年份
int startYear = 2009;
int currentYear = DateTime.Now.Year;
for (int year = startYear; year <= currentYear; year++)
{
comboBox1.Items.Add(year.ToString());
}
//默认设置为当前年份
comboBox1.SelectedIndex = comboBox1.Items.Count-1;
}
WinForms中通过下拉框ComboBox获取年份
最新推荐文章于 2024-08-31 14:48:17 发布