Thread: TComboBox and lack of item index on Object Inspector

  1. #1
    Registered User
    Join Date
    Dec 2001
    Posts
    11

    Question TComboBox and lack of item index on Object Inspector

    Hi all...

    Ok, here's the question...I know radio buttons automatically have a feature (Item Index) that can be set to 0 (instead of -1) to automatically have the first item pre-selected when the program runs. I noticed that the TComboBox has no Item Index displayed on the Object Inspector to do the same. (Borland 5.0)

    My program is already written, I just need some help on either a code setting the item index to the first item for the drop down Combo Box, or a code checking to make sure that the user selected one of the TStrings before computing, or ANY advice that anyone has. Any ideas?

    Thanks for your help!

    Christina

  2. #2
    Davros
    Guest
    Set the ComboBox style to csDropDownList. This makes the component behave as a simple drop down list, rather than a combination of an edit box & drop down list. Set the list items you want using the 'Items' property.

    There is no design time property to pre-select the list item. However, you can do it at run-time when your form is created with:

    ComboBox1->ItemIndex = 1;

  3. #3
    Registered User
    Join Date
    Dec 2001
    Posts
    11

    Talking

    Works beautifully...had to set ItemIndex=0 to get the first item to show, not the second. Thanks for the help!! It was along the lines of what I was thinking, just wanted a second opinion.

    Christina

Popular pages Recent additions subscribe to a feed