1
votes

I am trying to store the ComboColorBox.Color property in a database field through LiveBindings in a Firemonkey Project. I want to store the hexadecimal AlphaColor value, but the hex color value is automatically converted to a decimal value and not an AlphaColor.

I've searching in the LiveBindings documentation and found that I can change the value of control property before is stored in database writing a binding expression in CustomParse property of the Binding. The problem is that there is no built in function to convert an AlphaColor to a String in an expression.

Do I have to write a custom function to do that? How do I write that function and where? Or there is another solution?

1
There's an example of using color values with livebindings, here: docwiki.embarcadero.com/RADStudio/Tokyo/en/… - Dave Nottage

1 Answers

1
votes

You should know that a TAlphaColor is an integer, or more precisley a cardinal as defined in System.UITypes

type TAlphaColor = Cardinal;

Thus you can apply any integer to string conversion functions, like:

Label1.Text := IntToStr((Sender as TComboColorBox).Color);    // decimal notation
Label2.Text := IntToHex((Sender as TComboColorBox).Color, 8); // hexadecimal notation

So, to store the TAlphaColor value as a hexadecimal string, you would convert the color value using IntToHex(). On the other hand, Are you sure you really want to store it in the db as a string in the first place.