Date Check Item Code Item Name
20-10-2023 9001 C01 Green Car
20-10-2023 9002 C02 Brown Car
20-10-2023 9002 C03 Red Car
is it possible to change the format into,
Header Check Date
Item name Item Code Item Name
Header 9001 20-10-2023
Item name C01 Green Car
Header 9002 20-10-2023
Item name C02 Brown Car
Item name C03 Red Car
Check out the sample code in the Documentation for “WebListBoxStyleRenderer”. You can populate a listbox and call (apply) a Style to a cell (or whole row).
I was trying to change the format of listbox1 content, into new format which is contain Header and Item.
here is the code in button pressed,
var rowMax as Integer = ListBox1.LastRowIndex
var rowIndex, checkNumber, lastCheckNumber as Integer
while rowIndex <= rowMax
checkNumber = ListBox1.CellTextAt(rowIndex, 1).ToInteger
if checkNumber > lastCheckNumber then
if lastCheckNumber > 0 then
ListBox1.AddRowAt(rowIndex, "Header")
rowIndex = rowIndex + 1
rowMax = rowMax + 1
end if
ListBox1.AddRowAt(rowIndex, "Item")
rowIndex = rowIndex + 1
rowMax = rowMax + 1
dim gg as integer
gg=rowMax+2
lastCheckNumber = checkNumber
end if
rowIndex = rowIndex + 1
wend
and the listbox celltextpaint code
'Listbox1.InvalidateCell(row,column)
if Listbox1.CellTextAt(row,0)="Header" then
dim gg as integer
gg=row+2
Listbox1.CellTextAt(row,1)=Listbox1.CellTextAt(gg,1)
Listbox1.CellTextAt(row,2)=Listbox1.CellTextAt(gg,2)
Listbox1.CellTextAt(row,3)=Listbox1.CellTextAt(gg,3)
end if
I dont know how to move it into the right position.
Public Sub Transform(lb As DesktopListBox)
If lb.HeaderAt(0)<>"Date" Then
MessageBox("list is already transformed")
Return
End If
Var headers() As ClassHeader
Var lastCheck As String = ""
Var header As ClassHeader
For row As Integer = 0 To lb.LastRowIndex
Var cellDate As String = lb.CellTextAt(row,0)
Var cellCheck As String = lb.CellTextAt(row,1)
If cellCheck <> lastCheck Then
header = New ClassHeader
header.Check = cellCheck
header.Date = cellDate
headers.Add(header)
lastCheck = cellCheck
End If
Var item As New ClassItem
item.Code=lb.CellTextAt(row,2)
item.Name=lb.CellTextAt(row,3)
header.Items.Add(item)
Next
lb.RemoveAllRows
lb.ColumnCount = 2
lb.HeaderAt(0)="Check / Item Code"
lb.HeaderAt(1)="Date / Name"
Var p As Pair
For Each header In headers
p = New Pair(header.Check,header.Date)
lb.AddRow(p.Left, p.Right)
For Each item As ClassItem In header.Items
p = New Pair(item.Code,item.Name)
lb.AddRow(p.Left, p.Right)
Next
Next
End Sub
ClassHeader
Public Property Date As String
Public Property Check As String
Public Property Items() As ClassItem
ClassItem
Public Property Code As String
Public Property Name As String
[quote=
Another alternative you can consider is piDog’s DataView class. It is pure Xojo code built upon a canvas, not subclassed from a ListBox. So it was able to implement TONS of stuff not easily supported by the standard Listbox class.
[/quote]
FWIW … Once I got DataView some years back now, I NEVER used a single Xojo listbox again. The functionality was clearly superior and I never encountered a problem that could not be solved with the component. Jim McKay (creator and proprietor of DataView) is easily accessible and helped me through a number of tough spots (sometimes even making a change to his software, creating a new revision in the process).
I have tried to add 2 columns more, but it still tells that only 2 arguments allowed.
I add new properties, still got the same error message.
how to modified this line code,
lb.HeaderAt(0)="Check / Item Code"
lb.HeaderAt(1)="Date / Name"
Var p As Pair
For Each header In headers
p = New Pair(header.Check,header.Date,header.test)
lb.AddRow(p.Left, p.Right)
For Each item As ClassItem In header.Items
p = New Pair(item.Code,item.Name,item.testclass)
lb.AddRow(p.Left, p.Right)
Next
Next
I have remove the pairs,
but the result is not as expected.
customer data was in cell 4.
If lb.HeaderAt(0)<>"Date" Then
MessageBox("list is already transformed")
Return
End If
Var headers() As ClassHeader
Var lastCheck As String = ""
Var header As ClassHeader
For row As Integer = 0 To lb.LastRowIndex
Var cellDate As String = lb.CellTextAt(row,0)
Var cellCheck As String = lb.CellTextAt(row,1)
If cellCheck <> lastCheck Then
header = New ClassHeader
header.Check = cellCheck
header.Date = cellDate
headers.Add(header)
lastCheck = cellCheck
End If
Var item As New ClassItem
item.Code=lb.CellTextAt(row,2)
item.Name=lb.CellTextAt(row,3)
item.Customer=lb.CellTextAt(row,4)
header.Items.Add(item)
Next
lb.RemoveAllRows
'lb.ColumnCount = 3
lb.HeaderAt(0)="Check / Item Code"
lb.HeaderAt(1)="Date / Name"
'Var p As Pair
For Each header In headers
lb.AddRow(header.Check,header.Date)
For Each item As ClassItem In header.Items
lb.AddRow(header.Check,header.Date,header.Pelanggan)
Next
Next