循环只影响索引0的任何想法?

时间:2017-05-07 12:34:42

标签: c# asp.net web-services loops

如果匹配字符串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;
       }

0 个答案:

没有答案