[英]How to code a generic ComboBox to force a user to select a suggested entry?
This is an extension for: How to force a user to take a suggested entry into a ComboBox? 这是对以下内容的扩展: 如何强制用户将建议的条目输入ComboBox?
How can a solution using events (like Leave and SelectedIndexChanged) be implemented in a generalized way? 使用事件(例如Leave和SelectedIndexChanged)的解决方案如何以一种通用的方式实现? For example: I have implemented those methods for many comboboxes with a common behavior;
例如:我已经为许多具有共同行为的组合框实现了这些方法。 the code is the same for Leave event on all Combos, so I think I can subclass or use a partial class but I do not know how to do it in an architecturally proper way or if I could use a new subclassed component in VSTS2010 GUI editor.
该代码对于所有Combo上的Leave事件都是相同的,所以我认为我可以继承或使用部分类,但是我不知道如何以适当的体系结构方式进行操作,或者我是否可以在VSTS2010 GUI编辑器中使用新的子类组件。
Try to think this as creating a customized combo that has to enforce the user to write a value already existing in its related DataSource
尝试将其视为创建自定义组合,该组合必须强制用户写入其相关
DataSource
已经存在的值
创建一个从ComboBox
继承(而不是从UserControl
继承)的自定义控件,然后将所有逻辑放入其中。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.