用户在文本框输入数据,文本框下面自动提示
来源:互联网 发布:淘宝淘口令设置 编辑:程序博客网 时间:2024/06/06 22:57
1 系统预测的数据,我是放在listbox当中。
2 listbox 的高度随着数据变化
3 当匹配个数小于2时,自动隐藏。
效果如下。。。
具体代码如下:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Collections;
namespace 输入提示
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void cha_Click(object sender, EventArgs e)
{
{
}
List<string> test = new List<string>();
private void textBox1_TextChanged(object sender, EventArgs e)
{
listBox1.Visible = true;
listBox1.Items.Clear();
String str=textBox1.Text.Trim();
for (int i = 0; i < test.Count; i++) {
if ( test[i].ToString().Contains(str)) {
listBox1.Items.Add(test[i].ToString());
}
}
if (listBox1.Items.Count < 2)
{
listBox1.Hide();
}
else {
listBox1.Height = listBox1.Items.Count * 14;
}
List<string> test = new List<string>();
private void textBox1_TextChanged(object sender, EventArgs e)
{
listBox1.Visible = true;
listBox1.Items.Clear();
String str=textBox1.Text.Trim();
for (int i = 0; i < test.Count; i++) {
if ( test[i].ToString().Contains(str)) {
listBox1.Items.Add(test[i].ToString());
}
}
if (listBox1.Items.Count < 2)
{
listBox1.Hide();
}
else {
listBox1.Height = listBox1.Items.Count * 14;
}
}
private void Form1_Load(object sender, EventArgs e)
{
test.Add("1");
test.Add("12");
test.Add("123");
test.Add("123");
test.Add("1234");
test.Add("122");
test.Add("12345");
listBox1.Hide();
}
{
test.Add("1");
test.Add("12");
test.Add("123");
test.Add("123");
test.Add("1234");
test.Add("122");
test.Add("12345");
listBox1.Hide();
}
private void listBox1_SelectedIndexChanged(object sender, EventArgs e)
{
listBox1.Hide();
textBox1.Text =listBox1.SelectedItem.ToString();
}
}
}
{
listBox1.Hide();
textBox1.Text =listBox1.SelectedItem.ToString();
}
}
}
0 0
- 用户在文本框输入数据,文本框下面自动提示
- 在文本框中提示用户输入内容格式的方法
- 在文本框中提示用户输入内容格式的…
- JS实现在文本框输入时自动弹出相关内容提示
- AJAX实现文本框输入自动提示功能
- ASP.NET输入文本框自动提示功能
- ASP.NET输入文本框自动提示功能
- ASP.NET输入文本框自动提示功能
- 文本框输入提示
- 文本框提示输入
- 文本框输入提示2
- Ajax文本框输入提示
- 用户填写提示文本框
- 自动提示的文本框
- 自动提示的文本框
- 文本框自动提示功能
- 自动提示文本框应用
- android 自动提示文本框
- Vertex and fragment shader examples
- 2016年我国能源行业大数据的发展现状及市场分析
- 我看AlexNet
- 【HDOJ 5820】Lights(扫描线+线段树)
- HDU-5418 Victor and World(状压+spfa)
- 用户在文本框输入数据,文本框下面自动提示
- 夏令营day6总结
- 为模态对话框添加拖拽
- linux系统与51单片机实现串口数据交互
- 字符串 KMP HDU 3746
- C语言数组元素地址作为函数参数
- android app 快速接入银联支付流程(android studio版)
- Qt5在VS调试中可视化查看QString、QByteArray的解决方法
- C++ int与string的转化