private void textBox1_TextChanged(object sender, EventArgs e)
{
if (textBox1.Text.Trim().Length == 0)
listBox1.Visible = false;
else
{
listBox1.Visible = true;
var mlist = new string[listBox1.Items.Count];
for (int i = 0; i < listBox1.Items.Count; i++)
mlist[i] = listBox1.Items[i].ToString().Trim();
listBox1.Items.Clear();//不可缺少,要不会多次增加
foreach (var o in mlist)
{
var str = textBox1.Text.Trim().ToLower();
if (str.Substring(0, str.Length) == str)
{
listBox1.Items.Add(o);//不可缺少
listBox1.SelectedIndex = listBox1.FindStringExact(str); //完全区配后会标记栏位
}
}
}
}
{
if (textBox1.Text.Trim().Length == 0)
listBox1.Visible = false;
else
{
listBox1.Visible = true;
var mlist = new string[listBox1.Items.Count];
for (int i = 0; i < listBox1.Items.Count; i++)
mlist[i] = listBox1.Items[i].ToString().Trim();
listBox1.Items.Clear();//不可缺少,要不会多次增加
foreach (var o in mlist)
{
var str = textBox1.Text.Trim().ToLower();
if (str.Substring(0, str.Length) == str)
{
listBox1.Items.Add(o);//不可缺少
listBox1.SelectedIndex = listBox1.FindStringExact(str); //完全区配后会标记栏位
}
}
}
}