如果匹配字符串t1
,则更改lbxcityTours.SelectedIndex i
的内容
string t1 = abcdefg;
int i = 0;
while(i < lbxcityTours.Items.Count)
{
lbxcityTours.SelectedIndex = i;
if (lbxcityTours.SelectedItem.ToString() == t1)
{
work.Text = lbxcityTours.SelectedIndex.ToString();
lbxcityTours.SelectedItem.Value = "0";
//remove the selected item from the listbox
lstBoxAddedTours.Items.Remove(lstBoxAddedTours.SelectedItem);
}
i += 1;
}