i want check if item array appears in combobox before adding item combobox, avoid duplicates.
i not allowed use linq
code:
private void tooncategorien() { cbocategorie.items.clear(); foreach (string scategorie in marrcategorie){ if (!cbocategorie.items.contains(scategorie)) { comboboxitem cboitem = new comboboxitem(); cboitem.content = scategorie; cbocategorie.items.add(cboitem); } } }
sorry using dutch in c# code.
so marrcategorie array contains categories read streamreader. problem adds anyway. assume problem in if-loop.
i tried if(cbocategorie.text.contains(scategorie)) no result.
i not allowed post pictures directly yet, sorry using hyperlink):
thanks in advance!
solution, bolu:
private void tooncategorien() { cbocategorie.items.clear(); foreach (string scategorie in marrcategorie){ if (!cbocategorie.items.contains(scategorie)) { cbocategorie.items.add(scategorie); } } }
you comparing string
comboboxitem
here, think can use string: e.g:
private void tooncategorien() { cbocategorie.items.clear(); foreach (string scategorie in marrcategorie){ if (!cbocategorie.items.contains(scategorie)) { cbocategorie.items.add(scategorie); } } }
Comments
Post a Comment