ListBox displayed text

Hi.
How to get the selected displayed (not the bound) text from a ListBox?
For e.g.

MsgBox "You selected" & the_displayed_text

(There is a good .pdf on macros for Base, but I lost it.)
Thanks in advance!

Hi

I attach a draft document of mine I’m using wrt ListBoxes management:
LibO_Listboxes_v_0_0_3.odt (48.0 KB)
Note this really a draft that may contain errors :face_with_hand_over_mouth:

I tried .selectedItem without and with parenthesis.
?
Some context: was trying a possible answer for

Use a choice from a drop-down sourced from a query as a query parameter

And the routine I tried works just fine. But for a confirming message I put the bound value, which is not convenient for an user, of course.


SelectedItem

You haven’t shown how oLBB is defined.
You will need the view, not the model for getting selectedItem.

If you got the model this will be the part you need:

oController = oDoc.getCurrentController()
oView = oController.getControl(oLBB)
print oView.SelectedItem

You could try it directly with

SUB ListView
oField = thisComponent.Drawpage.Forms(0).getByName("MyListbox")
stView = oField.StringItemList(oField.SelectedItems(0))
msgbox stView
END SUB

Might be this helps: Chapter 9 Macros

Yes, it worked.
Thank you.
And yes: it’s this publication, but in “printed” (.pdf) format.

And also thank you @jfn: it’s very close!