Reading cell renderer value

in reply to Converting WebListBoxStyleRenderer back to Text? - TypeMismatchException - Web - Xojo Programming Forum
from the xojo forum

@TeeTomTerrific

  1. new web project
  2. add a listbox to the layout
  3. 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
  1. add a button
  2. 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
1 Like

Yeah I had already figured out that I needed to get the value from the WebListBoxStyleRenderer

Var ls As String
Var w As WebListBoxStyleRenderer
If listbox1.CellTextAt(row,col) IsA WebListBoxStyleRenderer Then
  w = listbox1.CellTextAt(row,col)
  ls = w.Value
Else
  ls = listbox1.CellTextAt(row,col)
End If