When I use the code modify ComBox. Items Items, such as the original article 5, modified to article 4, the modified automatically triggers the event?
ComBox, Items, the original collection is {0,10,20... 160} the following code, traverse delete specified part,
Foreach (string str2 boBoxDJ in this.com. The Items)
{
If (str2!="60" | | str2!="80" | | str2!="100" | | str2!="120" | | str2!="140")
{
ComboBoxDJ. Items. Remove (str2);
}
}
After execution foreach error, set the modified; May not be able to perform the enumeration operation,
ComBox registered its dynamic SelectedIndexChanged event, the above code in dynamic events,
CodePudding user response:
Into a for loop, and to reset the lengthCodePudding user response:
Foreach not allowed to modify the collection,For it
CodePudding user response:
SelectedIndexChanged only option changes,About your mistakes, upstairs said is right, foreach read collection is read-only object,
CodePudding user response:
Foreach can't delete the new, change the for