WebListBox.SelectionStyle

Perhaps there is some trick to this but I can’t seem to change the WebListbox SelectionStyle at runtime. Anyone else run into this?

It’s working for me but there are some properties of the style you have to explicitly set. For example the text color goes to white unless you force the style to have it set to black.

Well, I can set it at design type but not runtime. For example, we have data in some cells that Red (think accounting app). When the selection gets moved to that row it destroys the existing cell formatting and replaces it with the white text (or whatever the SelectionStyle is.

What I need is for some way to keep the cell formatting so that it’s still red (even if it’s unreadable - that’s what the client wants). So I tried to fake it with changing the SelectionStyle when the row is changed to one of them that has the special formatting.

Doesn’t seem to work for me.

For me I’m setting it at runtime through code. I override the text color and background style to look “normal” and override the default selected style and its working.

Worst case you might be able to loop through using CellStyle on that row and set the styles.

I’d be curious exactly how you’re doing that. Are you digging down into the web framework?

Maybe it works because I do it in the open event before the control is “shown”.
See if that gives you different results.

My code is pretty simple in the open event.

dim lb as WebListBox = ListBox1 lb.Style = StyleTextCentered lb.ColumnStyle(0) = StyleLink lb.SelectionStyle = StyleListboxSelectedIgnore lb.HeaderStyle = StyleCenteredBold

Yeah, I can’t do that. Selection style depends on the data which is variable.

Well if the variable has to be chosen after the shown event has already occurred then you could always remove and replace the listbox by putting it in a control array or in a web container.

===edit
I’m personally moving to a WebStyleTheme class where each user can pick a different theme and the theme can dynamically provide styling for Buttons, Dialogs, List Items, etc…

<https://xojo.com/issue/36941>

I included a sample project