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. vue打包体积优化之旅

    webpack 与 vue 在使用vue开发时,遇到打包后单个文件太大,因而需要分包,不然加载时间太久.虽然尽可能减少请求次数,但是单个包太大也不是好事 思路 组件按需加载 vue-router 的懒 ...

  2. bzoj3400

    题解: dp f[i][j]表示前i个,膜为j 最后记得判断0 代码: #include<bits/stdc++.h> using namespace std; ; int n,m,a[N ...

  3. 【Html 学习笔记】第七节——表单

    文本框:<form> <input> </form> 密码域-文本框:<input type ="password" > 复选框:& ...

  4. SpringXML方式配置bean的自动装配autowire

    Spring的自动装配,也就是定义bean的时候让spring自动帮你匹配到所需的bean,而不需要我们自己指定了. 例如: User实体类里面有一个属性role 1 2 3 4 5 6 7 publ ...

  5. week10《java程序设计》作业总结

    week10<java程序设计>作业总结 1. 本周学习总结 1.1 以你喜欢的方式(思维导图或其他)归纳总结异常相关内容. 答:: 2. 书面作业 本次PTA作业题集异常 1. 常用异常 ...

  6. eclipse集群tomcat

    eclipse集群tomcat 1.  File -> new -> other 选择server. 2.  选择Apache下边对应的tomcat版本,配置tomcat名称即可.由于我本 ...

  7. APUE学习笔记——10.18 system函数 与waitpid

    system函数 system函数用方便在一个进程中执行命令行(一行shell命令). 用法如下: #include <stdio.h> #include <stdlib.h> ...

  8. The program environment for cypress cy8ckit-002

    customer use cypress ic to make sure the  wireless products, we are prepare to establish the environ ...

  9. Shell 命令行 从日志文件中根据将符合内容的日志输出到另一个文件

    Shell 命令行 从日志文件中根据将符合内容的日志输出到另一个文件 前面我写了一篇博文Shell 从日志文件中选择时间段内的日志输出到另一个文件,利用循环实现了我想要实现的内容. 但是用这个脚本的同 ...

  10. Shell 命令行获取本机IP,grep的练习

    Shell 命令行获取本机IP,grep的练习 在 mac 下面输入 ifconfig 或者在 linux 下面输入 ip a 就可以得到我们的网卡信息.不过通常情况下,我们需要查看的是我们的IP地址 ...