[英]How to remove Multiple Items from RadComboBox
我有一個如下的RadComboBox
<radC:RadComboBox ID="lstMaterial" runat="server" Width="100px" Height="100px" DropDownWidth="100px" />
在aspx.cs頁面中,根據條件需要從上面的RadComboBox控件中添加和刪除多個項目,如下所示。
if(isTrue)
{
//Remove
List<string> strRemoveList = new List<string>();
strRemoveList.Add(lstMaterial.FindItemByText("Wood1").ToString());
strRemoveList.Add(lstMaterial.FindItemByText("Seam").ToString());
strRemoveList.Add(lstMaterial.FindItemByText("wood2").ToString());
// lstMaterial.Items.Remove(strConstructionStyleRemoveList);
//foreach(RadComboBoxItem rcbi in lstConstructionStyle.Items)
// {
// rcbi.Remove(strRemoveList);
// }
}
我相信您遇到的錯誤是由於從foreach循環的源中刪除了項。 嘗試改為循環strRemoveList,然后在該循環內從rcbi中刪除。
例:
foreach(string itemToRemove in strRemoveList)
{
rcbi.Remove(itemToRemove);
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.