我有一个名为 cmbWeekDays 的 ComboBox,一个WeekDay
类:
public class WeekDay
{
public int Index;
public string DayName;
}
这个 FormLoad 事件:
List<WeekDay> days = new List<WeekDay>();
days.Add(new WeekDay { DayName = "Sat", Index = 1 });
days.Add(new WeekDay { DayName = "Sun", Index = 2 });
days.Add(new WeekDay { DayName = "Mon", Index = 3 });
days.Add(new WeekDay { DayName = "Tue", Index = 4 });
days.Add(new WeekDay { DayName = "Wed", Index = 5 });
days.Add(new WeekDay { DayName = "Thu", Index = 6 });
days.Add(new WeekDay { DayName = "Fri", Index = 7 });
cmbxWeekDays.DataSource = days;
cmbxWeekDays.DisplayMember = "DayName";
cmbxWeekDays.ValueMember = "Index";
cmbxWeekDays.Refresh();
我不知道为什么会得到这个奇怪的结果:
谁能解释我发生了什么?以及如何克服这个问题?