Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 384975
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T15:26:00+00:00 2026-05-12T15:26:00+00:00

I want to add values to combobox in C++ builder 6. I know I

  • 0

I want to add values to combobox in C++ builder 6.
I know I can add string to combobox by string list editor.

For example, I have added this list to combobox:

car
ball
apple
bird

I want behind each text, it has their own value, so I can get the value rahter than the text when user selected a text. Just like HTML select.

But when I try to add value to each text:

ComboBox1->Items->Values[0] = "mycar";
ComboBox1->Items->Values[1] = "aball";
etc...

it will add more text to the list, like

car
ball
apple
bird
0=mycar
1=aball

This is not what I want. I don’t want the extra text to add to the list.
So, how can I add values to each text properly, and get the value?

  • 1 1 Answer
  • 1 View
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-12T15:26:00+00:00Added an answer on May 12, 2026 at 3:26 pm

    If you want to store the values in the ComboBox itself, then you need to use the Objects[] property instead of the Values[] property, for example:

    ComboBox1->Items->Objects[0] = (TObject*) new String("mycar");
    ComboBox1->Items->Objects[1] = (TObject*) new String("aball");
    ...
    String value = * (String*) ComboBox1->Items->Objects[ComboBox1->ItemIndex];
    ...
    delete (String*) ComboBox1->Items->Objects[0];
    delete (String*) ComboBox1->Items->Objects[1];
    

    As you can see, this requires managing dynamically allocated String objects. A better option would be to store the values in a separate list, such as a TStringList or std::vector, like PoweRoy suggested. As long as that list has the same number of items as the ComboBox, you can use ComboBox indexes to access the values, for example:

    TStringList *MyValues = new TStringList;
    ...
    MyValues->Add("mycar");
    MyValues->Add("aball");
    ...
    String value = MyValues->Strings[ComboBox1->ItemIndex];
    ...
    delete MyValues;
    

    Or:

    #include <vector>
    
    std::vector<String> MyValues;
    ...
    MyValues.push_back("mycar");
    MyValues.push_back("aball");
    ...
    String value = MyValues[ComboBox1->ItemIndex];
    ...
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a list of string values that I want add to a hashtable
I want to Add Values to my combobox in Datareader. This is my code,
I want to add some values in arraylist but at random index. Is this
I'm developing web-application, in this I want to add all months values on the
I have this report formatting tool development task and i want to add my
I have an Enumeration whitch values I want to aliment to a Combobox. Enum
I have A Class which is used to add Values to Combobox(One is used
I want to insert row for each day to add new values, and I
If I want to add a value in an array, I can use: $array[]
I have a dropdownlist.I want to add selected value of it to a hyperlink

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.