こんにちはリストボックスにリストの項目があります。 Landen、Lucie、812-692-5576、Jig Is Up 名前や電話番号、または比率で検索する必要があります.... 。 リストボックスでコンマで区切って検索すると
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()の実行時にnullになります; 'ので、あなたはその行の後にselectedItemを割り当てています –
@このことを強調してくれてありがとう、ありがとうございました。今更新されました。 –
素晴らしい..!今すぐその良い答え –