Problem mit Listboxen und Mehrfachauswahlen ...

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

Moderator: Moderatoren

Christian K.
**
Beiträge: 24
Registriert: Mi, 20.07.2005 10:55
Kontaktdaten:

Problem mit Listboxen und Mehrfachauswahlen ...

Beitrag von Christian K. »

Hallo,

ihr kennt doch die Auswahlmenus die z.B. bei OOo im Base Modul bei den ganzen Wizards eingesetzt werden. Da wo man 2 große Listboxen hat, und mit Pfeilen lassen sich alle bzw. einzelne Einträge von einer Box in die andere Bewegen.

Genau sowas bräuchte ich, und habe auch schon was Programmiert. Nur leider verhällt sich mein Programm sehr "komisch".
Einträge verändern sich, werden tw. doppelt aufgeführt und tw gar nicht bewegt.
Es wäre nett wenn sich den Code mal jemand anschauen könnte!

Danke!

Code: Alles auswählen

REM  *****  BASIC  *****
Dim oConnect as Object
Dim oDat as Object
Dim oxStatement as Object
Dim oDia as Object
Dim oErgebnis as Object

Sub Start


	Dim oDK as Object
	
	oDK = createUnoService( "com.sun.star.sdb.DatabaseContext" )
	oDat = oDK.getByName ( "neu" )
If Not oDat.isPasswordRequired Then
	oConnect = oDat.GetConnection("","")
Else
	InteractionHandler = createUnoService("com.sun.star.sdb.InteractionHandler")
	oConnect = oDat.ConnectWithCompletion(InteractionHandler)
End If
	DialogLibraries.loadLibrary ("Standard")
	oDia = CreateUnoDialog(DialogLibraries.Standard.Test)
'	zaehler = 1
	oDia.execute()
End Sub

Sub Beenden

oDialog.endExecute()
	
	If Not IsNull(oErgebnis) then
		oErgebnis.close()
	End If
	
		If Not IsNull(oxStatement) then
		oxStatement.close()
	End If
	
		If Not IsNull(oConnect) then
		oConnect.close()
	End If	
End Sub

Sub datenSatzRechts

	Dim items(4) as String
	Dim position(4) as Integer
	Dim x as Long
	
'	b = oDia.getControl("ListBox1").ItemCount
	items() = oDia.getControl("ListBox1").SelectedItems
	position() = oDia.getControl("ListBox1").SelectedItemspos()
	
	for i = lbound(position()) to ubound(position())
    oDia.getControl("ListBox1").removeItems(position(i), 1)
'   MsgBox position(i)
  	next i   
	oDia.getControl("ListBox2").addItems(items(), 1)
	
	
End Sub 

Sub datenSatzRechtsAlle

	Dim items(4) as String
	Dim b
	
	b = oDia.getControl("ListBox1").ItemCount
	items() = oDia.getControl("ListBox1").Model.stringItemList
	oDia.getControl("ListBox2").addItems(items(), 1)
	oDia.getControl("ListBox1").removeItems(0, b)
	
End Sub

Sub alleDatensatzLoeschen

	Dim items(4) as String
	Dim b
	
	b = oDia.getControl("ListBox2").ItemCount
	items() = oDia.getControl("ListBox2").Model.stringItemList
	oDia.getControl("ListBox1").addItems(items(), 1)
	oDia.getControl("ListBox2").removeItems(0, b)
	
End Sub

Sub datensatzLoeschen

	Dim items(4) as String
	Dim position(4) as Integer
	Dim x as Long
	
	b = oDia.getControl("ListBox2").ItemCount
	items() = oDia.getControl("ListBox2").SelectedItems
	position() = oDia.getControl("ListBox2").SelectedItemspos()
	
	for i = lbound(position()) to ubound(position())
    oDia.getControl("ListBox2").removeItems(position(i), 1)
'   MsgBox position(i)
  	next i   
	oDia.getControl("ListBox1").addItems(items(), 1)
	
End Sub
ykcim
*****
Beiträge: 324
Registriert: Di, 29.07.2003 15:22
Wohnort: Neu-Isenburg
Kontaktdaten:

Beitrag von ykcim »

Hi,

die Schleife zum Löschen der Einträge kann nicht funktionieren.
In dem Moment in dem der ersten Eintrag gelöschst wird, stimmen die Positionsangaben nicht mehr.

Du liest aus:

Position 1 - Wert: Eins
Position 2 - Wert: Zwei
Position 3 - Wert: Drei

Nach dem löschen von Position 2

Position 1 - Wert: Eins
Position 2 - Wert: Drei

Du mußt also nach jedem Löschen eines Items die Postitionen neu einlesen.

Oder die Itemliste durchgehen und jeweils nach der Position fragen und diese dann löschen ( Siehe GetItemPos Bibliothek Tools modul Listbox)

mfg
Michael
__
FAQ zu Starbasic -> http://www.starbasicfaq.de
Antworten