问题
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.
回答1:
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;
}
}
}
Check the following Tutorial: AutoComplete TextBox In WinForms Windows Forms Application
来源:https://stackoverflow.com/questions/11238602/c-sharp-textbox-show-previous-written-texts