I want to view rows from a database which is populated into a listbox.
I need the listbox(Listbox Source) to be shown on second listbox(listbox Destination) and textfield.
Window1.Listbox1.DeleteAllRows
Window1.L_guest.text=Listbox1.cell(Listbox1.ListIndex,1)
Window1.l_hp.text=Listbox1.cell(Listbox1.ListIndex,2)
dim ct As integer = 0
Window1.Listbox1.AddRow ""
dim h as integer
for h=0 to Listbox1.ListCount-1
Window1.listBox1.cell(ct,1)=listBox1.cell(h,5)
Window1.listBox1.cell(ct,2)=listBox1.cell(h,6)
Window1.listBox1.cell(ct,3)=listBox1.cell(h,7)
Window1.listBox1.cell(ct,4)=listBox1.cell(h,8)
Window1.listBox1.cell(ct,5)=listBox1.cell(h,9)
next
ct = ct + 1
Textfield showing correct result, but the listbox only show the last row from source listbox (listbox source)
Also, using: Window1.listBox1 and listBox1 is confusing: where is located that line of code ?
If it is somewhere inside Window1, you are in troubles… both references goes to the same ListBox Control.
hi,
Yes, its 10 Columns on source listbox, and also pushbutton is on window2.
I am using other method to save as file, its worked normally.
dim TextOut as textoutputstream
dim f as new folderitem
f=getfolderitem("data").Child("test.open")
TextOut = f.CreateTextFile
TextOut.Writeline Listbox1.cell(listbox1.ListIndex,0)
TextOut.Writeline Listbox1.cell(listbox1.ListIndex,1)
TextOut.Writeline Listbox1.cell(listbox1.ListIndex,2)
TextOut.Writeline Listbox1.cell(listbox1.ListIndex,3)
TextOut.Writeline Listbox1.cell(listbox1.ListIndex,4)
dim i as integer
for i=0 to listBox1.listcount-1
TextOut.writeline listBox1.cell(i,5)
TextOut.writeline listBox1.cell(i,6)
TextOut.writeline listBox1.cell(i,7)
TextOut.writeline listBox1.cell(i,8)
TextOut.writeline listBox1.cell(i,9)
next
TextOut.Close
Yes,
I do and I have modified it, then its worked now.
Dim numrows, numcols As Integer
Dim r, c As Integer
numrows = listbox1.listcount - 1
Window1.Listbox1.DeleteAllRows
Window1.L_guest.text=Listbox1.cell(Listbox1.ListIndex,1)
Window1.l_hp.text=Listbox1.cell(Listbox1.ListIndex,2)
For r = 0 to numrows
Window1.Listbox1.AddRow ""
For c = 0 to numcols
Window1.listbox1.cell(r, 1) = listbox1.cell(r, 5)
Window1.listbox1.cell(r, 2) = listbox1.cell(r, 6)
Window1.listbox1.cell(r, 3) = listbox1.cell(r, 7)
Window1.listbox1.cell(r, 4) = listbox1.cell(r, 8)
Window1.listbox1.cell(r, 6) = listbox1.cell(r, 9)
Next c
Next r
By the way, the For c does nothing, so you could change this:
to this:
For r = 0 To numrows
Window1.Listbox1.AddRow "", _
listbox1.cell(r, 5), _
listbox1.cell(r, 6), _
listbox1.cell(r, 7), _
listbox1.cell(r, 8), _
listbox1.cell(r, 9)
Next r
to make things a little neater, this adds a row and uses the values from the other listbox at the same time so you don’t have to add a blank row then populate it.