using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms; namespace _04TextBox
{
public partial class Form1 : Form
{
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[];
System.Security.Cryptography.RNGCryptoServiceProvider rng = new System.Security.Cryptography.RNGCryptoServiceProvider();
rng.GetBytes(bytes);
return BitConverter.ToInt32(bytes, );
} public Form1()
{
InitializeComponent(); //2000W数据,这里会有卡顿现象,这里修改为200W
for (int i = ; i < ; 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;
} private void Form1_Load(object sender, EventArgs e)
{ } }
}

提示内容,加个变量跟两个事件

#region 实现提示文字
Boolean textboxHasText = false;//判断输入框是否有文本
/// <summary>
/// textbox获得焦点
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void textBox1_Enter(object sender, EventArgs e)
{
if (textboxHasText == false)
textBox1.Text = ""; textBox1.ForeColor = Color.Black;
} /// <summary>
/// textbox失去焦点
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void textBox1_Leave(object sender, EventArgs e)
{
if (textBox1.Text == "")
{
textBox1.Text = "提示内容";
textBox1.ForeColor = Color.LightGray;
textboxHasText = false;
}
else
textboxHasText = true;
}
#endregion

winform Textbox模糊搜索实现下拉显示+提示文字的更多相关文章

  1. mui 修改下拉刷新提示文字的显示位置

    第一种: .mui-bar-nav~.mui-content .mui-pull-top-pocket { top: 126px !important; } 第二种: .mui-pull-top-po ...

  2. winform c#绑定combobox下拉框 年度代码。

    winform c#绑定combobox下拉框 年度代码. comboBox1.Items.AddRange("});//邦定数据 comboBox1.Text = DateTime.Now ...

  3. DataGridView单元格内容自动匹配下拉显示

    页面显示数据使用的控件是ComponentFactory.Krypton.Toolkit中的KryptonDataGridView控件.在指定“商品”单元格中需要根据用户输入内容自动匹配数据库中商品信 ...

  4. 完美解决,浏览器下拉显示网址问题 | 完美解决,使用原生 scroll 写下拉刷新

    在 web 开发过程中我们经常遇到,不想让用户下拉看到我的地址,也有时候在 div 中没有惯性滚动,就此也出了 iScroll 这种关于滚动条的框架,但是就为了一个体验去使用一个框架好像又不值得,今天 ...

  5. java简单的实现搜索框的下拉显示相关搜索功能

    最近做了一个简单的搜索框下面下拉显示相关搜索的功能,有点模仿百度的下拉展示相关搜索 先上个展示图 : 点击进入演示地址,大家可以输入长点的搜索,点击搜索,再输入之前搜索词的前面部分,看是否能展示出来 ...

  6. ASP.NET TextBox 当鼠标点击后清空默认提示文字

    ASP.NET TextBox 当鼠标点击后清空默认提示文字 [ 方法一] 前台代码: <div>    <asp:TextBox ID="txtName" ru ...

  7. android 项目学习随笔十一(ListView下拉刷新提示)

    1. 设置mHeaderView.setPadding TOPPADING为负值,隐藏刷新提示头布局 在onTouchEvent事件中进行头布局显示隐藏切换 import java.text.Simp ...

  8. QT实现输入框与下拉框提示并可模糊匹配

    功能:支持下拉框选择.手动输入更改和模糊匹配 组件:QLineEdit.QComboBox.QCompleter.QStringListModel 一.组件介绍 1.1 QLineEdit QLine ...

  9. JQuery 简单的文字超出部分隐藏下拉显示

    HTML代码: <body> <div class="txt_bos"><!--在每一个放置文字的class外面包一个div,以便设置动画样式用,同样 ...

随机推荐

  1. 【原创】移动端获取用户公网ip,获取用户ip

    有时候某些api需要获取用户的ip , 特此分享一下获取用户公网ip的方法 纯js <script src="http://pv.sohu.com/cityjson?ie=utf-8& ...

  2. CodeForces 297A Parity Game (脑补题)

    题意 一个01串,可以有两种操作:①在末尾添加parity(a):②删除开头的一个字符.其中parity(a),当串中1的个数为奇数时为1,偶数时为0.问某个01串是否可以通过若干操作变成另一个01串 ...

  3. 【转】c++析构函数(Destructor)

    创建对象时系统会自动调用构造函数进行初始化工作,同样,销毁对象时系统也会自动调用一个函数来进行清理工作,例如释放分配的内存.关闭打开的文件等,这个函数就是析构函数. 析构函数(Destructor)也 ...

  4. notepad配合正则表达式处理文本

    <option value="irs01.com">irs01.com</option><option value="hdslb.com&q ...

  5. 转:基于Flume的美团日志收集系统(一)架构和设计

    美团的日志收集系统负责美团的所有业务日志的收集,并分别给Hadoop平台提供离线数据和Storm平台提供实时数据流.美团的日志收集系统基于Flume设计和搭建而成. <基于Flume的美团日志收 ...

  6. python简单日志统计

    业务场景:在一个目录里,有许多日志文件,里面是一条条的json数据,格式如下,为防止一个账号被多个ip使用,现在我想知道:哪些用户登录了哪些ip,和哪些ip登录了哪些用户,如果一个ip对应一个用户,就 ...

  7. 如何将dom4j的jar包放到java项目中

    ---恢复内容开始--- 如果你建的是java project项目的话,那就通过Myeclispe中的右键你的项目名称,选择build path ->config build path... 然 ...

  8. C# http post上传文件

    using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.I ...

  9. 01-名字管理系统.py

    #-*- coding:utf-8 -*- #1.打印功能提示 print("-"*50) print("名字管理系统 V8.6") print("1 ...

  10. iOS开发-Realm数据库

    Realm Realm-Object-c,见:https://realm.io/cn/docs/objc/latest/Realm官网:https://realm.io 使用流程 导入头文件#impo ...