List<int> listYears = new List<int>(); for (int i = 5; i > -5; i--) { listYears.Add(DateTime.Now.Year - i); } cb_Year.ItemsSource = listYears; cb_Year.SelectedValue = DateTime.Now.Year ; /*SelectedValue计算后想显示的值要在源listYears中, 比如如果写成cb_Year.SelectedValue = DateTime.Now.Year - 8 ,会显示为空。 。欢迎拍砖*/
时间: 2024-12-25 19:52:48