Aloha
OOo Wiki hat geschrieben:The list box control that supports the interface com.sun.star.awt.XListBox offers more convenient functions than the list box model. For example, it offers the method
selectItemPos( [in] short nPos,[in] boolean bSelect ) to select or deselect a single item in the list box.
Ich hab den wichtigen Teil aus Deinem Link mal fett markiert.
Mit
kriegst Du aber das Model (com.sun.star.comp.forms.OListBoxModel), nicht das Control der Listbox.
Um auf die Methoden des Interfaces (wie auch
selectItemPos) zuzugreifen, benötigst Du das Control der ListBox (com.sun.star.comp.forms.OListBoxControl), welches das Interface XListBox unterstützt.
Code: Alles auswählen
oDoc = StarDesktop.CurrentComponent
oForm = oDoc.DrawPage.Forms.GetByIndex(0)
oList= oForm2.getByName("Liste") '<-------------- Hier kriegst Du das Model
oListControl = oDoc.CurrentController.getControl(oList) '<----------------------- So bekommst Du Zugriff auf das Control der Listbox
REM oList.SelectedItemPos '<-- Model unterstützt das Interface XListBox nicht, daher nicht möglich
MsgBox oListControl.SelectedItemPos '<--- Control unterstützt das Interface, somit stehen auch dessen Methoden zur Verfügung