我试图将结构数组绑定到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
. 我做错什么了?