Hi *,

Jason Stephenson escribió:
You could also try something like this:

Sub DoThing
    Dim Form As Object
    Dim ListBox As Object
    Dim Controller As Object
    Dim ListBoxControlModel As Object

    ' Get controller for the current document
    Controller = ThisComponent.getCurrentController()

    ' Assuming first or only form
    Form = ThisComponent.Drawpage.Forms.getByIndex(0)
    ListBox = Form.getByName("ListBoxName") 'I prefer getByName().
    ListBoxControlModel = Controller.getControl(ListBox)

    ListBoxControlModel.selectItem("ItemTextToSelect", True)
    ' If it is a database/data form, you will want to do the following.
    ' Otherwise, you might not need the next line.
    ListBox.commit()
End Sub



I don't know if the above is quicker or easier than what Ariel suggested, but its the way that I typically do it in database forms when i need to select a particular item in a list box, usually based on some other control value.

they do different things. The one I explained does just what Fernand asked (supposing he was really asking how to set the *default* value). A default value is a value you can default, in this case using ::com::sun::star::form::XReset::reset().

Side comment to Frank:
this interface name doesn't sound correct, IMHO it'd make more sense a ::com::sun::star::form::XResetable just like:

store() ---> XStorable
close() ---> XCloseable
so
reset() ---> XResetable

Regards
Ariel
--
Ariel Constenla-Haile
La Plata, Argentina


"Aus der Kriegsschule des Lebens
                - Was mich nicht umbringt,
        macht mich härter."
                Nietzsche Götzendämmerung, Sprüche und Pfeile, 8.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@api.openoffice.org
For additional commands, e-mail: dev-h...@api.openoffice.org

Reply via email to