using System;
using System.Collections;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Text;
using System.Windows.Forms;
namespace DigitalCult
{
/// <summary>
/// Summary description for ACComboBox.
/// </summary>
public class ACComboBox : System.Windows.Forms.ComboBox
{ private bool autoComplete;
[DefaultValue(true),
Description("Auto-completes text if a match is found in the items collection."),
Category("Behavior")]
public bool AutoComplete
{
get { return autoComplete; }
set { autoComplete = value; }
}
/// <summary>
autoComplete combobox
最新推荐文章于 2025-01-13 12:17:16 发布
这个博客介绍了如何创建一个自定义的ACComboBox控件,该控件在用户输入时能自动完成匹配项。通过继承System.Windows.Forms.ComboBox,实现了一个包含AutoComplete属性的控件,当AutoComplete为true时,将在Items集合中搜索匹配项并自动选择。博客还提供了使用这个自定义控件的步骤,包括修改命名空间、替换原始ComboBox为ACComboBox以及设置初始化代码。
曾经在网上遇到过有人问关于自动填充的ComboBox的问题,当然没有在意,谁知道后来也因为软件开发需要碰到了同样的问题。于是只好到处找资料,谁知道网上的仅仅只能实现自动填充的功能,并不能象IE栏一样,碰到有相同的信息,可以展开ComboBox并高亮选中的内容。( 比容,ComboBox下有3天记录,分别是:eqweq,fasdfs,tyr”当我在输入字符e的时候,应当文本框中显示eqweq并展开下拉框,选中eqweq)。百般无赖,只好对代码进行研究,经过稍稍的改动,已经可以实现我所预想的功能,源代码如下:

最低0.47元/天 解锁文章
1023

被折叠的 条评论
为什么被折叠?



