C# textbox show previous written texts(C# 文本框显示以前的书面文本)
问题描述
例如,如果您访问 facebook 并双击登录文本框,那么会有一些以前有人写的登录.有什么方法可以在 C# 文本框上进行先前输入的下拉列表吗?我不想要组合框.
For example if you go to facebook and press double click on the login textbox, then there are some Logins that previous someone wrote. Is there any way to make this dropdown of previous inputs on C# textbox? I don't want combobox.
推荐答案
参见TextBox.AutoCompleteMode 和 TextBox.AutoCompleteSource 文本框的属性.您需要在以下几行中做一些事情:
See the TextBox.AutoCompleteMode and TextBox.AutoCompleteSource properties of the TextBox. You need to do something on the following lines:
namespace WindowsApplication1
{
public partial class Form1 : Form
{
AutoCompleteStringCollection autoComplete = new AutoCompleteStringCollection();
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
autoComplete.Add(textBox1.Text);
}
private void Form1_Load(object sender, EventArgs e)
{
textBox1.AutoCompleteMode = AutoCompleteMode.SuggestAppend;
textBox1.AutoCompleteSource = AutoCompleteSource.CustomSource;
//auto.Add(textBox1.Text);
textBox1.AutoCompleteCustomSource = autoComplete;
}
}
}
查看以下教程:在 WinForms Windows 中自动完成文本框表格申请
这篇关于C# 文本框显示以前的书面文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:C# 文本框显示以前的书面文本
基础教程推荐
- 在 VB6 或经典 ASP 中使用 .NET 2022-01-01
- 从 C# 控制相机设备 2022-01-01
- 将数据集转换为列表 2022-01-01
- SonarQube C# 分析失败“不是指针的有效行偏移" 2022-01-01
- 如果条件可以为空 2022-01-01
- 更新 Visual Studio 中的 DataSet 结构以匹配新的 SQL 数据库结构 2022-01-01
- 重新排序 WPF TabControl 中的选项卡 2022-01-01
- 获取C#保存对话框的文件路径 2022-01-01
- C# 9 新特性——record的相关总结 2023-04-03
- Mono https webrequest 失败并显示“身份验证或解密失败" 2022-01-01
