I want to apply different styles to cells in the WebListBox depending on column element, in this case numbers should be right justified and sometimes but not all the time have some background color. The column elements making the list are stored in array.
The following snapshot illustrates what I want to do but can’t do obviously as it generates the error. So I need some help.
I haven’t played that much with Styles, so I usually have a Style for each combination I need, as:
vStyle
vStyle_rightjustify
… and so on
Other option is check if the WebStyle has the property/value that you want and add/delete as needed before use.
Not sure if a Feature Request can be done to add Styles as I don’t know what will happen if both styles have ‘text-align’ (for example) and one with ‘left’ and the other with ‘right’.
Well, I can certainly use Select Case for the combination to make it work.
The problem is that justification depends on the column element type (number will need to be right justified, the rest can be left as is), the background color on the other hand may have dependency on the other column elements. So the “right justify” is generic while the background color is more of the special case depending on the list layout.
Oh, I didn’t mention, but showing icon (aka image) in the cell might be another possibility - but I will leave it out of discussion for now.
If you know you want to add vStyle+vJustifyStyle then you could follow the same way to add/remove the justify to the Style, no?
You can add the CSS property with Value (we already did that in another topic)
You can check if the Style has the property with WebStyle .HasCSSProperty and you can remove the property with .Remove
I’m more visual, if you have problems to figure out options please upload a sample project to see it in action.
Well, I may not be communicating this how I want. This snapshot shows how I can create the WebStyle first before applying to the cell in the data source class that pertains to specific web page/weblistbox layout.
All I want is to separate the code that handles justification vs cell background color, the justification can go to superclass and the background color to the subclassed datasource.
I think I have now a good idea how to refactor this.