2

我应该改用什么?我已经尝试过 DataBindings.Add ,但我的数据没有加载我有具有 3 个属性的数据结构:ID、名称和例如描述。我想将整个数据加载到列表中,但只显示 Name 属性。通常我为此目的使用 DisplayMember,但我在这里找不到它。

4

3 回答 3

5

DisplayMember 和 ValueMember 被标记为不可浏览,因此使用 Intellisense 时它们是不可见的。这是 CheckedListBox 类元数据:

// Summary:
//     Gets or sets a string that specifies a property of the objects contained
//     in the list box whose contents you want to display.
//
// Returns:
//     A string that specifies the name of a property of the objects contained in
//     the list box. The default is an empty string ("").
[EditorBrowsable(EditorBrowsableState.Never)]
[Browsable(false)]
public string DisplayMember { get; set; }

无论如何,它们实际上可以使用,只需将它们用作具有正确大小写的属性,并且您不应该收到任何设计时错误。

于 2012-10-02T14:41:18.060 回答
1

同样来自MSDN

注意:您不能将数据绑定到 CheckedListBox。为此,请使用 ComboBox 或 ListBox。有关详细信息,请参阅如何:将 Windows 窗体 ComboBox 或 ListBox 控件绑定到数据。

于 2009-11-26T22:21:21.397 回答
0

它被称为DisplayMemberMSDN链接。

于 2009-11-26T21:59:47.437 回答