autoComplete combobox

这个博客介绍了如何创建一个自定义的ACComboBox控件,该控件在用户输入时能自动完成匹配项。通过继承System.Windows.Forms.ComboBox,实现了一个包含AutoComplete属性的控件,当AutoComplete为true时,将在Items集合中搜索匹配项并自动选择。博客还提供了使用这个自定义控件的步骤,包括修改命名空间、替换原始ComboBox为ACComboBox以及设置初始化代码。
摘要由CSDN通过智能技术生成
曾经在网上遇到过有人问关于自动填充的ComboBox的问题,当然没有在意,谁知道后来也因为软件开发需要碰到了同样的问题。于是只好到处找资料,谁知道网上的仅仅只能实现自动填充的功能,并不能象IE栏一样,碰到有相同的信息,可以展开ComboBox并高亮选中的内容。( 比容,ComboBox下有3天记录,分别是:eqweq,fasdfs,tyr”当我在输入字符e的时候,应当文本框中显示eqweq并展开下拉框,选中eqweq)。百般无赖,只好对代码进行研究,经过稍稍的改动,已经可以实现我所预想的功能,源代码如下:

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; }

评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值