【发布时间】:2010-07-07 18:48:30
【问题描述】:
我正在尝试将结构数组绑定到 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。我做错了什么?
【问题讨论】:
标签: winforms data-binding c#-3.0 combobox