You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users-de@openoffice.apache.org by Horst <te...@jrsch.de> on 2016/02/13 22:27:15 UTC
Item in Listbox Vorgeben
Hallo,
ich quäle mich mit der Listbox rum.
Ich habe eine Listbox mit 50 Einträgen und ich möchte, dass der Zeiger
auf den 30. Eintrag gesetzt wird, so dass der sichtbar ist.
Der Sinn dahinter ist, dass ich zwei Listboxen koppeln möchte. In der
Einen steht z.B. rot an Pos. 30. Wenn ich das wähle soll die andere auf
"red" springen auch an Pos. 30.
/i/st umständlich, ich weiß, aber die Einträge in der Listbox lassen
sich sonst nicht als Tabelle darstellen. Oder doch?
Horst
Re: Item in Listbox Vorgeben
Posted by Oliver Brinzing <Ol...@gmx.de>.
Hallo Horst,
> ich quäle mich mit der Listbox rum.
Um was geht es genau?
Eine Listbox in einem Dialog oder ein Kontrolelement in einem Calc/Writer Dokument?
Gruß
Oliv er
---------------------------------------------------------------------
To unsubscribe, e-mail: users-de-unsubscribe@openoffice.apache.org
For additional commands, e-mail: users-de-help@openoffice.apache.org
Re: Item in Listbox Vorgeben
Posted by Oliver Brinzing <Ol...@gmx.de>.
Hallo Horst,
> Das Makro läuft zwar, aber ich glaube anders als gewollt. Die Items werden zwar richtig rausgegeben
> aber in der Box nicht angezeigt. Nur das ausgewählte Element. Doch das ist nicht wo wichtig.
Bei mir funktioniert das.
Hast Du auch den Entwurfsmodus bei den Steuerelementen abgeschaltet?
> Aber ich hatte von einer Listbox in einem Dialog gesprochen. DA funktionierte das ganze nicht.
Die ListBox im Dialog ist identisch, nur der Zugriff auf das Model bzw. Control unterscheidet sich:
Sub DialogcontrolExample()
Dim mItems()
mItems() = Array("1","2","3")
oLibContainer = DialogLibraries
oLibContainer.LoadLibrary("Standard")
oLib = oLibContainer.getByName("Standard")
oLibDialog = oLib.getByName("MyDialog")
oRuntimeDialog = CreateUnoDialog(oLibDialog)
oListBoxControl = oRuntimeDialog.getControl("ListBox1")
oListBoxModel = oListBoxControl.getModel()
oListBoxModel.StringItemList() = mItems()
oListBoxModel.insertItemText(0, "Hello")
oListBoxModel.insertItemText(4, "World")
oListBoxModel.selectedItems() = Array(2)
oRuntimeDialog.execute()
MsgBox oListBoxControl.selectedItem & Chr(13) & oListBoxControl.selectedItemPos & Chr(13) &
oListBoxControl.ItemCount
End Sub
Gruß
Oliver
---------------------------------------------------------------------
To unsubscribe, e-mail: users-de-unsubscribe@openoffice.apache.org
For additional commands, e-mail: users-de-help@openoffice.apache.org
Re: Item in Listbox Vorgeben
Posted by Horst <te...@jrsch.de>.
Hallo Oliver,
Das Makro läuft zwar, aber ich glaube anders als gewollt. Die Items
werden zwar richtig rausgegeben
aber in der Box nicht angezeigt. Nur das ausgewählte Element. Doch das
ist nicht wo wichtig.
Aber ich hatte von einer Listbox in einem Dialog gesprochen. DA
funktionierte das ganze nicht.
Horst
Am 15.02.2016 um 19:40 schrieb Oliver Brinzing:
> REM ***** BASIC *****
> Sub ListBoxExample()
> Dim oDoc as Object
> Dim oView as Object
> Dim oDrawPage as Object
> Dim oForms as Object
> Dim oListBoxModel as Object
> Dim oListBoxControl as Object
> Dim mItems()
>
> mItems() = Array("1","2","3")
>
> oDoc = ThisComponent
> oView = oDoc.getCurrentController()
>
> ' jede Tabelle hat eine DrawPage
> oDrawPage = oDoc.getDrawPages.getByIndex(0)
>
> If oDrawPage.hasElements() Then
> ' jede DrawPage kann mehrere Forms haben ...
> oForms = oDrawPage.getForms()
> If oForms.hasElements Then
> ' i.d.R. "Formular"
> oForm = oForms.getByIndex(0)
> If oForm.hasByName("Listenfeld 1") Then
> ' UnoControlListBoxModel - com.sun.star.awt.XItemList
> oListBoxModel = oForm.getByName("Listenfeld 1")
> oListBoxModel.Enabled = True
> oListBoxModel.DropDown = True
>
> oListBoxModel.StringItemList() = mItems()
> oListBoxModel.insertItemText(0, "Hello")
> oListBoxModel.insertItemText(4, "World")
> oListBoxModel.selectedItems() = Array(4)
>
> ' UnoControlListBox - com.sun.star.awt.XListBox
> oListBoxControl = oView.getControl(oListBoxModel)
> MsgBox oListBoxControl.selectedItem & Chr(13) &
> oListBoxControl.selectedItemPos & Chr(13) & oListBoxControl.ItemCount
>
> oListBoxControl.selectItemPos(2, True)
> MsgBox oListBoxControl.selectedItem & Chr(13) &
> oListBoxControl.selectedItemPos & Chr(13) & oListBoxControl.ItemCount
>
> oListBoxControl.addItem("XXX", 5)
>
> oListBoxControl.selectItemPos(1, True)
> MsgBox oListBoxControl.selectedItem & Chr(13) &
> oListBoxControl.selectedItemPos & Chr(13) & oListBoxControl.ItemCount
> EndIf
> EndIf
> EndIf
> End Sub
---------------------------------------------------------------------
To unsubscribe, e-mail: users-de-unsubscribe@openoffice.apache.org
For additional commands, e-mail: users-de-help@openoffice.apache.org
Re: Item in Listbox Vorgeben
Posted by Oliver Brinzing <Ol...@gmx.de>.
Hallo Horst,
Szenario: In der ersten Tabelle eines Tabellendokuments ist ein Listenfeld mit dem Namen "Listenfeld
1" vorhanden.
Dann sollte das Beispiel funktionieren:
REM ***** BASIC *****
Sub ListBoxExample()
Dim oDoc as Object
Dim oView as Object
Dim oDrawPage as Object
Dim oForms as Object
Dim oListBoxModel as Object
Dim oListBoxControl as Object
Dim mItems()
mItems() = Array("1","2","3")
oDoc = ThisComponent
oView = oDoc.getCurrentController()
' jede Tabelle hat eine DrawPage
oDrawPage = oDoc.getDrawPages.getByIndex(0)
If oDrawPage.hasElements() Then
' jede DrawPage kann mehrere Forms haben ...
oForms = oDrawPage.getForms()
If oForms.hasElements Then
' i.d.R. "Formular"
oForm = oForms.getByIndex(0)
If oForm.hasByName("Listenfeld 1") Then
' UnoControlListBoxModel - com.sun.star.awt.XItemList
oListBoxModel = oForm.getByName("Listenfeld 1")
oListBoxModel.Enabled = True
oListBoxModel.DropDown = True
oListBoxModel.StringItemList() = mItems()
oListBoxModel.insertItemText(0, "Hello")
oListBoxModel.insertItemText(4, "World")
oListBoxModel.selectedItems() = Array(4)
' UnoControlListBox - com.sun.star.awt.XListBox
oListBoxControl = oView.getControl(oListBoxModel)
MsgBox oListBoxControl.selectedItem & Chr(13) & oListBoxControl.selectedItemPos & Chr(13) &
oListBoxControl.ItemCount
oListBoxControl.selectItemPos(2, True)
MsgBox oListBoxControl.selectedItem & Chr(13) & oListBoxControl.selectedItemPos & Chr(13) &
oListBoxControl.ItemCount
oListBoxControl.addItem("XXX", 5)
oListBoxControl.selectItemPos(1, True)
MsgBox oListBoxControl.selectedItem & Chr(13) & oListBoxControl.selectedItemPos & Chr(13) &
oListBoxControl.ItemCount
EndIf
EndIf
EndIf
End Sub
Gruß
Oliver
---------------------------------------------------------------------
To unsubscribe, e-mail: users-de-unsubscribe@openoffice.apache.org
For additional commands, e-mail: users-de-help@openoffice.apache.org
Re: Item in Listbox Vorgeben
Posted by Horst <te...@jrsch.de>.
Hallo Jörg,
danke erst einmal:
Am 14.02.2016 um 09:22 schrieb Jörg Schmidt:
> Hallo,
> den 30. Eintrag gesetzt wird, so dass der sichtbar ist.
> Z.B.
> http://www.starbasicfaq.de/KannmanListboxeneintrgeberdiePositionsel.html#Zweig109
die Eigenschaft /selectitempos /ist nicht bei meiner Listbox vorhanden,
jedenfalls ergab das eine Fehlermeldung
> Mehr Info:
> http://www.starbasicfaq.de/WelchessinddieBesonderheitenvonListboxen.html
Auch da scheint es Änderungen gegeben haben, etliches läuft davon nicht.
Zumindes nicht bei mir
> http://www.openoffice.org/api/docs/common/ref/com/sun/star/awt/XListBox.html
Ja, da steht das das gibt. Aber ohne Beispiel, wie ich so was aufrufe
bin ich aufgeschmissen. Da fehlt mir der komplette Background
>
>
> Gruß
> Jörg
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-de-unsubscribe@openoffice.apache.org
> For additional commands, e-mail: users-de-help@openoffice.apache.org
>
Re: Item in Listbox Vorgeben
Posted by Jörg Schmidt <jo...@j-m-schmidt.de>.
Hallo,
> From: Horst [mailto:technik_div@jrsch.de]
> ich quäle mich mit der Listbox rum.
> Ich habe eine Listbox mit 50 Einträgen und ich möchte, dass
> der Zeiger
> auf den 30. Eintrag gesetzt wird, so dass der sichtbar ist.
Z.B.
http://www.starbasicfaq.de/KannmanListboxeneintrgeberdiePositionsel.html#Zweig109
Mehr Info:
http://www.starbasicfaq.de/WelchessinddieBesonderheitenvonListboxen.html
http://www.openoffice.org/api/docs/common/ref/com/sun/star/awt/XListBox.html
Gruß
Jörg
---------------------------------------------------------------------
To unsubscribe, e-mail: users-de-unsubscribe@openoffice.apache.org
For additional commands, e-mail: users-de-help@openoffice.apache.org