Dialog ListBox mit Array befüllen

Programmierung unter AOO/LO (StarBasic, Python, Java, ...)

Moderator: Moderatoren

surfhai
**
Beiträge: 28
Registriert: Di, 17.08.2004 08:42

Dialog ListBox mit Array befüllen

Beitrag von surfhai »

Hallo,

ich möchte in OO 1.1.5 ein Dialog öffnen mit den Namen der einzelnen Sheets. Allerdings bekomme ich in die ListBox mein Array nicht rein.

Code: Alles auswählen


Sub Main

		'Sheets Auslesen
		myDoc = thisComponent
		Anzahl = myDoc.Sheets.count
	
	Dim SheetNames(1) As Variant
	
		For x = 0 To Anzahl - 1
			mySheet = myDoc.Sheets(x)
			ReDim Preserve SheetNames(x) As Variant
			SheetNames(x) = mySheet.Name
			'MsgBox(SheetNames(x))
		Next x
		
		For x = 0 To UBound(SheetNames())
			If SheetNames(x) = "Einstellungen" Then
				'ArrayDelete(SheetNames(), x)
			End If
			'MsgBox(SheetNames(x))
		Next x
		
		Dim oDialog1 As Object
		Dim oListBox1 As Object
	
		oDialog1 = LoadDialog("Standard", "DlgAuswahl")
		oListBox1 = oDialog1.getControl("test")
		
		oListBox1.Items = SheetNames()
		
		'GlobalScope.BasicLibraries.LoadLibrary("Tools")
		'WriteDbgInfo(oListBox1)
		'MsgBox(oDialog1.dbg_properties)
		
		oDialog1.execute
End Sub


Jetzt komm ich einfach nichtmehr weiter.

Gruß Thorsten
ykcim
*****
Beiträge: 324
Registriert: Di, 29.07.2003 15:22
Wohnort: Neu-Isenburg
Kontaktdaten:

Beitrag von ykcim »

Hallo,

so geht es:

Code: Alles auswählen

Sub Main

      'Sheets Auslesen
      myDoc = thisComponent
      Anzahl = myDoc.Sheets.count

      Dim oDialog1 As Object
      Dim oListBox1 As Object
      Dialoglibraries.Loadlibrary("Standard")
      oDialog1= CreateUnoDialog(Dialoglibraries.Standard.DlgAuswahl)

      oListBox1 = oDialog1.getControl("test")

   
      For x = 0 To Anzahl - 1
         mySheet = myDoc.Sheets(x)
         if mySheet.Name<>"Einstellungen" then olistbox1.additem(mySheet.Name,x)
      Next x
      
      oDialog1.execute
End Sub 

mfg
Michael
__
FAQ zu Starbasic -> http://www.starbasicfaq.de
surfhai
**
Beiträge: 28
Registriert: Di, 17.08.2004 08:42

Beitrag von surfhai »

Hallo Michael,

danke für den Code, der funktioniert sogar und ist zudem noch optimiert :)

Gruß Thorsten
Antworten