选择项目时,Combobox显示重复项目 [英] Combobox displays duplicate items when an item is selected

查看:758
本文介绍了选择项目时,Combobox显示重复项目的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Windows窗体上有一个数据绑定组合框。当我选择一个项目时,所有其他绑定的组件都会正确更新。但是,下拉项目的列表会更改,以便所选项目在列表中重复。例如,以下是原始列表:

I have a data-bound combobox on a Windows form. When I select an item, all of the other bound components update properly. However, the list of drop-down items changes so that the selected item is duplicated in the list. For example, here is the original list:

这是我选择项目时的列表:

This is what the list looks like when I select an item:

组合框绑定到bindingsource从LINQ到SQL查询获取其数据。显示成员是SpecName,值成员是SpecID,选定值是bindingsource中的SpecID字段。

The combobox is bound to a bindingsource that gets its data from a LINQ to SQL query. The Display Member is the SpecName, the Value Member is the SpecID and the Selected Value is the SpecID field in the bindingsource.

如何更正此重复行为? p>

How can I correct this duplication behavior?

推荐答案

当我遇到类似情况时,原因是组合框Databindings | Text属性。

When I encountered a similar situation, the cause was the combobox Databindings|Text property.

当此属性设置为相关绑定源和显示字段时,我可以复制所描述的行为。

I could duplicate the behavior described when this property was set to the relevant binding source and display field.

将属性设置为None导致行为终止

Setting the property to None caused the behavior to cease.

这篇关于选择项目时,Combobox显示重复项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆