2012-02-01 123 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