曾经在网上遇到过有人问关于自动填充的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; }