How to set default Listbox item

I have the following code to show a Listbox in a macro

oSheet = ThisComponent.Sheets.getbyname("Templates")
DialogLibraries.loadLibrary( "Standard" )
dlg_Listbox = DialogLibraries.Standard.dlg_Listbox
odlg_Listbox = CreateUnoDialog( dlg_Listbox )
oListbox = odlg_Listbox.GetControl("Listbox")
oListbox.addItem ("kg",0)
oListbox.addItem ("st",0)
oListbox.addItem ("l",0)
oListbox.addItem ("Kopje Gerecht",0)
oListbox.addItem ("Kop Lunch Diner",0)

if odlg_Listbox.execute then
’ print "Success, you selected: " & oListbox.SelectedText
endif

When the listbox shows no item is selected and displayed yet. How can I display a default item, for example the 3rd one.
listbox

selectItem()

Default text or record in a listbox

1 Like