How can I add items programatically into combo box control during runtime?
I am trying like this.
expcombo.Items.Add(expcombo.Text); But given item is not saved. when I close the form and run the form again.. combo box is not showing that given item.
I changed above statement like this
Here I am getting a numeric value like 1 even though I entered string value.
Pls somebody help me. I am trying for this from long back

9 Years
Discussion Span
Last Post by ddanbe

Look, object (application, controls, textbox, combobox, etc...) data saved in machine memory, so when your application closed all its data removed.
To do your scenario, to add an item then close the application, and when you start it again, you find this item, you should have data repository (SQL Server, MySQL, XML, etc...) holds combobox items.



I wonder how you can let this work, expcombo.Items.Add(expcombo.Text) isn't a string.
expcombo.Text is a property of the entire combobox, why do you want to show it as a selectable item in the combobox itself?


As RamyMahrous says, the items you add during runtime aren't saved anywhere. The items you put in during design are hardcoded and will always be there. The ones you add during runtime have to be saved by you before closing your app(many options here) and loaded back in when your app starts up.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.