简体   繁体   English

displaymember中的C#组合框索引

[英]C# Combobox index in displaymember

I have a combobox that has a BindingList as its DataSource. 我有一个具有BindingList作为其数据源的组合框。 I've set the displaymember to the property I want being displayed. 我已将displaymember设置为要显示的属性。 For some objects in that list the property is empty so I would like to display the index of the object inside that BindingList (preferably a combination of both, the index followed by the property). 对于该列表中的某些对象,该属性为空,因此我想在该BindingList中显示该对象的索引(最好是两者的组合,索引后跟该属性)。 How can I let the index be displayed inside the combobox and not a property (I can't get the index inside the object so I can't create a new property)? 如何让索引显示在组合框内而不是属性内(我无法在对象内部获取索引,所以无法创建新属性)?

The dropdownlist asks for the name of the property and doesn't accept any logic to attach to it. 下拉列表要求提供属性名称,并且不接受任何附加逻辑。 So you have to add an extra column to your datasource consists of the information from those two columns. 因此,您必须在数据源中添加额外的一列,其中包括来自这两列的信息。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM