WeekDay
クラス である cmbWeekDays という名前の ComboBox があります。
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();
なぜこの奇妙な結果が得られるのかわかりません:
何が起こっているのか説明してくれる人はいますか?また、この問題を克服する方法は?