Re: combobox in sheet per makro füllen
Verfasst: So, 14.02.2010 18:31
OOo Version?
Ist das wirklich eine Combobox?
Ist das wirklich eine Combobox?
deutsches Forum rund um Apache OpenOffice und LibreOffice
https://oooforum.de/
Code: Alles auswählen
oComboBox = Doc.CurrentController.getControl(Form.getByName("Name_combobox"))
Code: Alles auswählen
Sub FL_Fuellen
Dim oDoc as Object
Dim oDocCtl as Object
Dim oSheet as Object
Dim oDraw as Object
Dim oForm as Object
Dim oElement as Object
Dim oElementView as Object
Dim s
oDoc = thisComponent
oDocCtl = oDoc.getCurrentController()
oSheet = oDoc.sheets.GetByName ("Weight 2")
oDraw = oSheet.drawpage
oForm = oDraw.getForms.GetByName("Formular1")
oElement = oForm.getByName("ComboBox1")
oElementView = oDocCtl.getControl(oElement)
'MsgBox oElementView.dbg_properties
oCombobox1 = oElement
DatabaseContext = createUnoService("com.sun.star.sdb.DatabaseContext")
DataSource = DatabaseContext.getByName("Neue Datenbank5.1")
Connection = DataSource.GetConnection("","")
Statement = Connection.createStatement()
ResultSet = Statement.executeQuery("SELECT DISTINCT FR FROM Weight2")
i=0
If not isNull (ResultSet) then
Do while ResultSet.Next
i= i+1
s = Resultset.getString(1) '&'Chr(13)
Msgbox s
oComboBox1 = oElement
oComboBox1.removeItems(i-1, 5)
'oComboBox1.removeItems(i-1, oComboBox1.getItemCount()) 'schränkt ein wie viele gespeichert werden
oComboBox1.addItem(s,-1) ' beeinflusst ab was für einem Datensatz gespeichert wird
Loop
end if
end sub
hoffie hat geschrieben:Eigentlich wäre mir aber die Sache mit dem addItem und removeItem zunächst wichitger
Code: Alles auswählen
(...)
Do while ResultSet.Next
i= i+1
s = Resultset.getString(1) '&'Chr(13)
Msgbox s
oComboBox1 = oElementView '<---------------------------!
oComboBox1.removeItems(i-1, 5)
'oComboBox1.removeItems(i-1, oComboBox1.getItemCount()) 'schränkt ein wie viele gespeichert werden
oComboBox1.addItem(s,-1) ' beeinflusst ab was für einem Datensatz gespeichert wird
Loop
end if
end sub
Code: Alles auswählen
oDoc = thisComponent
oDocCtl = oDoc.getCurrentController()
oSheet = oDoc.sheets.GetByName ("Weight 2")
oDraw = oSheet.drawpage
oForm = oDraw.getForms.GetByName("Formular1")
oElement = oForm.getByName("ComboBox1")
oElement.ListSource = "SELECT `FL`FROM `mysql`.`weight` WHERE `ID1` = " & x