Adding new item to combobox

Please support our C# advertiser: Intel Parallel Studio Home
Reply

Join Date: Dec 2008
Posts: 13
Reputation: nmakkena is an unknown quantity at this point 
Solved Threads: 0
nmakkena nmakkena is offline Offline
Newbie Poster

Adding new item to combobox

 
0
  #1
Dec 26th, 2008
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
Reply With Quote Quick reply to this message  
Join Date: Aug 2006
Posts: 2,065
Reputation: Ramy Mahrous is just really nice Ramy Mahrous is just really nice Ramy Mahrous is just really nice Ramy Mahrous is just really nice 
Solved Threads: 256
Featured Poster
Ramy Mahrous's Avatar
Ramy Mahrous Ramy Mahrous is offline Offline
Postaholic

Re: Adding new item to combobox

 
0
  #2
Dec 26th, 2008
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.
BI Developer | LINKdotNET
B.Sc Computer Science, Helwan University
Technical blog | http://ramymahrous.wordpress.com
LinkedIn | http://www.linkedin.com/in/ramymahrous
Reply With Quote Quick reply to this message  
Join Date: Oct 2008
Posts: 1,917
Reputation: ddanbe has much to be proud of ddanbe has much to be proud of ddanbe has much to be proud of ddanbe has much to be proud of ddanbe has much to be proud of ddanbe has much to be proud of ddanbe has much to be proud of ddanbe has much to be proud of ddanbe has much to be proud of 
Solved Threads: 274
ddanbe's Avatar
ddanbe ddanbe is offline Offline
Posting Virtuoso

Re: Adding new item to combobox

 
0
  #3
Dec 26th, 2008
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.
Today is a gift, that's why it is called "The Present".
Make love, no war. Cave ab homine unius libri.
Danny
Reply With Quote Quick reply to this message  
Join Date: Oct 2008
Posts: 1,917
Reputation: ddanbe has much to be proud of ddanbe has much to be proud of ddanbe has much to be proud of ddanbe has much to be proud of ddanbe has much to be proud of ddanbe has much to be proud of ddanbe has much to be proud of ddanbe has much to be proud of ddanbe has much to be proud of 
Solved Threads: 274
ddanbe's Avatar
ddanbe ddanbe is offline Offline
Posting Virtuoso

Re: Adding new item to combobox

 
0
  #4
Dec 26th, 2008
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.
Today is a gift, that's why it is called "The Present".
Make love, no war. Cave ab homine unius libri.
Danny
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC