您好,我有一個列表框中的項目列表 Landen,Lucie,812-692-5576,Jig是Up 我需要搜索名稱或電話或Ratios .... 。 我已經輸入這個代碼,但他與搜索字符串ATT任何地方行在列表框中搜索,用逗號隔開
int x = 0;
string match = textBox1.Text;
if (textBox1.Text.Length != 0)
{
bool found = true;
while (found)
{
if (listBox1.Items.Count == x)
{
listBox1.SetSelected(lastMatch, true);
found = false;
textBox2.Text = listBox1.SelectedItem.ToString();
}
else
{
listBox1.SetSelected(x, true);
match = listBox1.SelectedItem.ToString();
if (match.Contains(textBox1.Text))
{
lastMatch = x;
found = false;
}
x++;
textBox2.Text = listBox1.SelectedItem.ToString();
}
}
太感謝你了
'listBox1.SelectedItem'將在'textBox2.Text = listBox1.SelectedItem.ToString執行()的時間空;'因爲您在該行之後分配selectedItem –
@un-lucky感謝您突出顯示這一點,我應該首先進行選擇。現在更新。 –
太棒了!現在它的正確答案 –