Bind the Styles property to a SQL Query


I have a table where I store “Machine states” and one of the fields is the color (stored as a string)

I tried to bind the style property of a component but the color columns is loaded as a string and not as a color.

I even tried that the result of the query to be something like this:


But it still interprets “color(255,0,0,255)” as a string

Is it possible to do this?

Thank you

Yes, if you bind the “Styles” dataset to a SQL query, the color columns can be represented as a string like:


I think your problem is that the name of the column isn’t matching the property to change. For example, if the property you want to change the color on is called “background” then the column in the styles dataset must be called “background”. You can use an alias in your query to rename columns:SELECT col AS background ....

Note that you also need columns called animationIndex and animationDuration in the resulting dataSet for the SQL bound styles to function correctly.

Thank you Travis, MCC,

I’ll try it right away.

Just one question: is it normal that when I see the contents of the “Style” Dataset in the designer (after filling it with the query) the “color” column displays “color(255,255,255,255)” instead of the colors and the color selector tool?

Thank you.

Yes, that is normal. You can’t return a Color data type from a SQL query.