943,929 Members | Top Members by Rank

Ad:
  • C# Discussion Thread
  • Unsolved
  • Views: 5184
  • C# RSS
Dec 26th, 2008
0

Adding new item to combobox

Expand Post »
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
Messagebox.show(expcombo.Items.Add(expcombo.Text));
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
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
nmakkena is offline Offline
14 posts
since Dec 2008
Dec 26th, 2008
0

Re: Adding new item to combobox

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.
Featured Poster
Reputation Points: 480
Solved Threads: 276
Postaholic
Ramy Mahrous is offline Offline
2,189 posts
since Aug 2006
Dec 26th, 2008
0

Re: Adding new item to combobox

Quote ...
Messagebox.show(expcombo.Items.Add(expcombo.Text));
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?
Last edited by ddanbe; Dec 26th, 2008 at 8:18 am.
Reputation Points: 2035
Solved Threads: 645
Senior Poster
ddanbe is offline Offline
3,740 posts
since Oct 2008
Dec 26th, 2008
0

Re: Adding new item to combobox

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.
Reputation Points: 2035
Solved Threads: 645
Senior Poster
ddanbe is offline Offline
3,740 posts
since Oct 2008

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in C# Forum Timeline: C# SendMessage to HTML document controls
Next Thread in C# Forum Timeline: C# Custom GUI





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC