0
我試圖將結構數組綁定到ToolStripCombobox,但沒有成功。將結構數組綁定到ToolStripCombobox
我試過使用它,就像在this的例子中,但是當我嘗試設置一個值成員時出現錯誤。
我的代碼如下所示:
public struct PlayTimeLength
{
public string Description;
public double Seconds;
public PlayTimeLength(string description, double seconds)
{
Description = description;
Seconds = seconds;
}
}
public PlayTimeLength[] PlayTimeLengths = {new PlayTimeLength("1 minuta", 1*60), new PlayTimeLength("3 minuty", 3*60), new PlayTimeLength("5 minut", 5*60)};
和實際的綁定代碼:
cbxTimes.ComboBox.DataSource = PlayTimeLengths;
cbxTimes.ComboBox.DisplayMember = "Description";
cbxTimes.ComboBox.ValueMember = "Seconds"; //<-- exception here
cbxTimes
是ToolStripCombobox
類型。我究竟做錯了什麼?