My program crashes sometimes when I type something in the textbox, but sometimes it does not crash...
private void textBox4_TextChanged(object sender, EventArgs e)
{
TextBox t = sender as TextBox;
if (t != null)
{
// say you want to do a search when user types 1 or more chars
if (t.Text.Length >= 1)
{
this.textBox4.AutoCompleteCustomSource.AddRange(Artikel);
}
}
}
Artikel
is a string array with a bunch of names
string[] Artikel;
The problem is that its a 50/50 thing, sometimes it crashes and sometimes it doesn't, even with the same characters I type inside the textbox.
CodePudding user response:
Adding as answer, to complete the Q&A, and so that others find the solution.
The OP has moved the assignment of the AutoCompleteCustomSource
property to the MouseClick
event handler instead of setting it inside the TextChanged
event handler.