Even running through the examples, I cannot find a way to set a cell color. This used to be a lot easier.
Would love to see CellFontColor() and CellBackgroundColor(), something with a few lines of code.
Even running through the examples, I cannot find a way to set a cell color. This used to be a lot easier.
Would love to see CellFontColor() and CellBackgroundColor(), something with a few lines of code.
Hi Derek, check the WebListBoxStyleCellRenderer class, it has an example in the documentation.
You will have to create an instance of WebListBoxStyleCellRenderer (you can reuse it later), set its BackgroundColor and ForegroundColor. Once you have the styles defined, use your Listbox’s CellValueAt to assign it.
There is also an example showing how to add some custom CSS in this forum:
How? how to apply all the cells with only one string? I tried cellOnly = false, but it doesn’t work. I like celltagat() because it allows us to use rowcount and columncount and inset inside the parameter.
Hi @Ricardo_Cruz_Fernandez
The documentation link gives a 404 page. When I search for WebListBoxStyleCellRenderer in the documentation nothing is found.
I did find WebListBoxCellRenderer (no style and no example) and WebListBoxStyleRenderer.
With the following code:
I’m getting this result:
It looks like WebListBoxStyleRenderer.CellOnly is being ignored for backgrounds. I’ve created Issue #76867, you can upvote if you want.
It is the WebListBoxStyleRenderer class.
That’s exactly the same as what I did with my populatelistbox. I’m glad I did the right thing even though I thought it was wrong. I want to upload mine in Issue #76867. Thank you.
Derek, I use Xojo2024R2 with the web app I am working on. I have created method in the web page with the following code:
Var vStyle As New WebStyle
Var vText As String
Var vCellContentVariant As Variant
Var vVarType As Integer
vCellContentVariant = BanksFileList.CellTextAt(pRowNo,pColNo)
vVarType = VarType(vCellContentVariant)
Select Case vVarType
Case 0 // TypeNil
Return
Case 8 // TypeString
vText = vCellContentVariant
Else
Return
End Select
Select Case pType
Case kLateWarningStyle
vStyle.BackgroundColor=Color.Yellow
vStyle.ForegroundColor=Color.Black
Case kLateAlertStyle
vStyle.BackgroundColor=Color.Red
vStyle.ForegroundColor=Color.White
Case kLateManualStyle
vStyle.ForegroundColor=Color.Blue
vStyle.Bold=True
Case kLateAutoStyle
vStyle.ForegroundColor=Color.Purple
Else
Return
End Select
Var vCellRenderer As New WebListBoxStyleRenderer(vStyle, vText)
vCellRenderer.CellOnly = True
BanksFileList.CellTextAt(pRowNo,pColNo) = vCellRenderer
// reset default values
Style.BackgroundColor=Color.White
Style.ForegroundColor=Color.Black
Style.Bold=False
where parameters are:
pRowNo As integer, pColNo As integer, pType As String
And this is how it is used when adding line to the WebListBox:
ApplyCellStyle (lineNum,13,kLateWarningStyle)// 2023.11.05 <gp> added
where kLateWarningStyle is a constant of type string ex: “LATE_WARNING_STYLE”