How to read all lines from TGListBox

Hello ROOTers,

I know, how to get selected items from TGListBox. However, I would like to list all entries, without remembering their IDs in any external array. Maybe the answer is obvious, but I do not see it now.

Thank you a lot!

OldA

Hi OldA,

The following code should print the entry Id and the text if the TGListBox contains text entries. // fListBox is a TGListBox TGLBContainer *lc = (TGLBContainer *)fListBox->GetContainer(); TGLBEntry *e; TGFrameElement *el; TIter next(lc->GetList()); while ((el = (TGFrameElement *) next())) { e = (TGLBEntry *) el->fFrame; printf("Entry: %d, %s\n", e->EntryId(), ((TGTextLBEntry *)e)->GetTitle()); }
Another way is doing that interactively. If you have the ROOT v5.14, run the macro $ROOTSYS/tutorials/gui/listBox.C. Move the mouse over the list box and hit ctrl+a keys to select all entries. Then set ON the multiple selection check button and print this selection via Show button.
There is no problem to provide a method doing that, if you need it.

Cheers, Ilka

Hi Ilka,

the code works fine, thank you! I was close to the solution, but not enough :slight_smile:

OldA