Hi all,
I’m a little stuck with something I’ve been testing and can’t work out why it’s not doing what I thought it would.
A simple window containing 2 listboxes, and a small test database with 4 rows.
The code below works perfectly to add the rows to Listbox1 using the usual method.
Then I have added additional code to populate Listbox2 within the same loop, with the intention of placing the text at specific co-ordinates, using the g.DrawString in the CellTextPaint event for Listbox2. The code is straight forward as below :
[code] Dim IncidentDB As New SQLiteDatabase
IncidentDB.DatabaseFile = GetFolderItem(“TestDB.sqlite”)
If Not IncidentDB.Connect Then
Msgbox(“Unable to connect to database”)
Else
Dim IncSet As RecordSet
Dim SQL As String = “Select * From TestData ORDER BY Incident”
IncSet = IncidentDB.SQLSelect(SQL)
If IncSet <> Nil Then
While Not IncSet.EOF
Listbox1.AddRow(IncSet.IdxField(2).StringValue)
JobID=IncSet.IdxField(2).StringValue
Listbox2.AddRow()
IncSet.MoveNext
Wend
End If
End If[/code]
JobID is set as a text property within a module.
When I run the program, this is the ouput :
The numbers in Listbox1 (Left) are correct, but Listbox 2 on the right only ever shows the last JobID value for every row; they should be identical to the ones on the left.
The CellTextPaint event for Listbox2 is:
g.DrawString JobID, 1, 17
I’ve also tried it using:
g.DrawString(JobID, 1, 17)
Also, for the Listbox2.AddRow, I’ve tried using:
Listbox2.AddRow
Listbox2.AddRow()
Listbox2.AddRow("")
But nothing seems to work. Data is being placed in JobID, and g.DrawString can see it, but it is not changing for each invocation of While… Wend.
I can’t think of any trigger or event that I’m missing.
Any thoughts folks ?
Thanks.