Select an Entry in TGComboBox with name


I have the following problem with TGComboBox item.
I would like to set the initial value of the combobox with the name of this entry, and not with id because I don’t know it. (How can i make an equivalent of Select(char *) ?)

I’ve tried this code but it doesn’t work, EntryId() always return 0

TGLBEntry * lbe1 = mycombo->FindEntry("x");
if (lbe1)


Hi Laurent,

I see no problem using your code if all entries were added to the combo box by using the method AddEntry as below: for (int i = fFirstEntry; i < fLastEntry; i++) { sprintf(tmp, "Entry%i", i+1); fCombo->AddEntry(tmp, i); } If I do:

TGLBEntry *lbel = fCombo->FindEntry("Entry5"); if (lbel) fCombo->Select(lbel->EntryId()); the “Entry5” is selected.

Cheers, Ilka

Thank you for your reply.

I’m confused, i had forgotten to give an index when adding entries … :confused:

That’s why it always returned me 0.

Now it works fine. Thanks.

Hi Laurent,

You are very welcome - I am glad that your code works fine.

Best regards, Ilka