winform让Textbox像百度一下实现下拉显示

原文出处:http://bbs.csdn.net/topics/390324804

作者:wawd74520


        List<string> Data = new List<string>();
 
        string Randomstr = "功夫撒黑胡椒hcbvf蜂窝qwertyuiopasdfghjklzxcvbnm法国的恢复到飞范德萨QWERTYUIOPASDFGHJKLZXCVBNM出现过热423贴①46546也有一头热刚恢复到贴3天赋如头3广泛的我让他";
 
 
        Random rd = new Random(GetRandomSeed());
 
        static int GetRandomSeed()
        {
            byte[] bytes = new byte[4];
            System.Security.Cryptography.RNGCryptoServiceProvider rng = new System.Security.Cryptography.RNGCryptoServiceProvider();
            rng.GetBytes(bytes);
            return BitConverter.ToInt32(bytes, 0);
        }
        public Form1()
        {
            InitializeComponent();
 
 
            for (int i = 0; i < 20000000; i++)
            {
                Data.Add(Randomstr.ToCharArray()[rd.Next(Randomstr.Length)].ToString()
                    + Randomstr.ToCharArray()[rd.Next(Randomstr.Length)].ToString()
                    + Randomstr.ToCharArray()[rd.Next(Randomstr.Length)].ToString()
                    + Randomstr.ToCharArray()[rd.Next(Randomstr.Length)].ToString()
                    + Randomstr.ToCharArray()[rd.Next(Randomstr.Length)].ToString());
            }
 
            this.textBox1.AutoCompleteCustomSource.Clear();
            this.textBox1.AutoCompleteCustomSource.AddRange(Data.ToArray());
            this.textBox1.AutoCompleteMode = System.Windows.Forms.AutoCompleteMode.SuggestAppend;
            this.textBox1.AutoCompleteSource = System.Windows.Forms.AutoCompleteSource.CustomSource;
 
        }



下面是2000W数据加载后的效果

效果还可以。就分享了

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值