I have the method ApplyCellStyle that changes background color of certain cells in certain rows in the WebListbox. This method was called from custom LineAdded event of the WebListbox in the old version of the app (Xojo2018) when using custom DbListbox class.
In Xojo2024R2.1 I have removed the custom DbListbox class since I want to use DataSource class. In the RowData method I can determine color code needed and write to Tag.
I need now to use this value with the line/colum number to change the cell background color by using custom ApplyCellStyle method.
I am not sure if I can do it from within DataSource.RowData method. How should I go about this?
Well, if it is possible indeed to change background color of the cell inside WebListbox using DataSource then the question is how to do it. If I knew how to do it for one cell then I can figure out how to adapt it for my needs. Maybe Ricardo can give me a hint?
Using the sample that comes with Xojo, simple checking if first name is âAbdulâ then use style background yellow, if not then green:
If you canât figure it out, here is the added/changed code:
Code used
Var style As New WebStyle
style.BackgroundColor = Color.Yellow
Var style2 As New WebStyle
style2.BackgroundColor = Color.Green
Var firstname As String = rs.Column("FirstName").StringValue
If firstname = "Abdul" Then
row.Value("FirstName") = New WebListBoxStyleRenderer(style, firstname)
Else
row.Value("FirstName") = New WebListBoxStyleRenderer(style2, firstname)
End If
'row.Value("FirstName") = rs.Column("FirstName").StringValue
Thank you, I can put the color on the background of the cell, it is too easy
I didnât know that the change to the cell has to be done through the ârow.Valueâ substitution before ârows.Add(row)â occurs. I wish I could find material on the web about this and read before wasting the proverbial âbandwidthâ on this forum, but then again, this falls into the âmanualâ section.
Anyway, Alberto, you have given me the right solution, thank you.
I didnât know either, but found Ricardoâs post and then I was able to create the sample above. Sorry if my last post feels harsh, but âmy solutionâ is in fact what Ricardo posted there.