in reply to Converting WebListBoxStyleRenderer back to Text? - TypeMismatchException - Web - Xojo Programming Forum
from the xojo forum
- new web project
- add a listbox to the layout
- put this code in the opening event of the listbox
'Create an empty row
Me.AddRow("")
'Create a webstyle
Var style As New WebStyle
style.BackgroundColor = Color.Yellow
style.BorderColor = Color.Green
style.BorderThickness = 3
Style.Bold = True
'Create a renderer from the webstyle and some text
Var cellRenderer As New WebListBoxStyleRenderer(style, "Hello World!")
'Assign the renderer to the cell
Me.CellTextAt(0,0) = cellRenderer
- add a button
- add its pushed event and put this code in it
Dim cellRenderer As WebListBoxStyleRenderer = Listbox1.CellTextAt(0,0)
dim s as string = cellRenderer.value
cell renderers seem to have a VALUE property that autocomplete shows but aren’t mentioned in the docs
to know if you got a cell renderer vs a string well …
if Me.CellTextAt(0,0) isa WebListBoxStyleRenderer then
// whatever you need to to get the text from the renderer
else if vartype(Me.CellTextAt(0,0)) = Variant.TypeString then
// its a string
end if