Adding multiple items to a combo box using AddRange

25,025

Solution 1

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.

Solution 2

You could try something like

cbo_Genre.Items.AddRange(new string[] {"Horror", "Comedy"});

Solution 3

This works in C# 4.0, using an implicitly typed array:

cbo_Genre.Items.AddRange(new[] {"Horror", "Comedy"});
Share:
25,025
John
Author by

John

Updated on May 13, 2020

Comments

  • John
    John about 4 years

    Baically I'm looking for something like this...

    cbo_Genre.Items.AddRange({"Horror", "Comedy"});