Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How do I add an entry to a ComboBox list?

Status
Not open for further replies.

BorlandDave

Programmer
Jun 13, 2005
86
GB
I have created a combo box with five entries using the Object Inspector. I now want to dynamically add a 6th entry to the list from within my code.

Any ideas how to do this? Cheers.
 
Look at the Items entry under TComboBox and AddObject in your help files. For example:
Code:
ComboBox1->Items->AddObject("vsIcon", (TObject *)vsIcon);

I must admit it's been a long time since I've done this.

James P. Cottingham
-----------------------------------------
I'm number 1,229!
I'm number 1,229!
 
Code:
ComboBox1->Items->Add (Fields->Field [0].c_str ());
ComboBox1->Items->Add ("something");
ComboBox1->Items->Add (Edit1->Text);
tomcruz.net
 
Thanks for the info. I did check the help file, but couldn't seem to work it out. I'll give your methods a try.
 
OK, that worked. But now, somewhere else in my code, if the new combobox item exists, I want to delete it.

Sorry to keep asking these simple questions, but I don't find the Borland help menu very helpful... and all the info I find on the net is for Microsoft VC++.
 
Nevermind, I worked it out:

if(ComboBox1->Items->Count >= 7){
ComboBox->Items->Delete(6);
}

The help file can be useful after all!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top