We have a modest form. And there is a modest ComboBox. And the code must specify the elements. That is, I have the text to be inserted into the Items property. Also in the environment. All anything, here only Items only returns values, but does not accept them. Therefore, I ask - how to do it?

Please do not throw ideas with data binding. For this exercise will take extra memory, and time is a pity.

  • one
    comboBoxName.Items.Add(некоторое_значение) - Ev_Hyper
  • 2
    Write in the answers, it is necessary somehow to give thanks to people))) - Mr. Don't know

2 answers 2

The ComboBox.Items property returns a collection of items contained in the ComboBox .

To add one item to the list, you can use the Add method.

 comboBox1.Items.Add(value); 

whereas for several elements you need to use the AddRange method

    Well, in general, in the documentation https://msdn.microsoft.com/ru-ru/library/system.windows.forms.combobox.items(v=vs.110).aspx at the bottom of the example code is given:

     comboBox1.Items.Add(textBox1.Text)