Adding multiple items to a combo box using AddRange
-
12-11-2019 - |
Question
Baically I'm looking for something like this...
cbo_Genre.Items.AddRange({"Horror", "Comedy"});
Solution
Have a look at this.
ComboBox1.Items.AddRange(new string[]{"Typical", "Compact", "Custom"});
cbo_Genre.Items.AddRange(new string[]{"Horror", "Comedy"});
AddRange
adds an array of items to the ComboBox.
OTHER TIPS
You could try something like
cbo_Genre.Items.AddRange(new string[] {"Horror", "Comedy"});
This works in C# 4.0, using an implicitly typed array:
cbo_Genre.Items.AddRange(new[] {"Horror", "Comedy"});
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow