2012-02-01 84 views

回答

1

嘗試使用Listbox.Text,Listbox 在ListBox中搜索與指定文本相匹配的項目並選擇該項目。

ListBox.Text= "string Value" ; 
+0

謝謝你,................... – 2012-02-02 09:05:47

+0

foreach(ListItem item in lbxempname.Items) { string neww = Convert.ToString(item); if(Convert.ToString(item)== Givenstring) { item.Selected = true; this.imgbtnedit_Click(null,null); } } – 2012-02-03 10:55:07

1

我認爲你正在尋找的東西是這樣的:

foreach (var item in ListBox.Items) 
{ 
    if (item.Text.Contains(stringToBeSearched)) 
    { 
     //select item in the ListBox 
     ListBox.SelectedValue = item.Value; 
     break; 
    } 
} 

希望這有助於。

+0

是的,謝謝你,我得到了結果。非常感謝你.. – 2012-02-02 09:04:34

+0

謝謝你的朋友。謝謝你。 – 2012-02-02 09:05:15

相關問題