I have this code to color grid row based on column data (the grid is from devexpress)
var
AColumn: TcxCustomGridTableItem;
gs: variant;
begin
AColumn := (Sender as TcxGridDBTableView).GetColumnByFieldName('COLOR');
gs := ARecord.Values[AColumn.Index];
if VarType(gs) and VarTypeMask = varString or varUString then
AStyle.Color := gs; //<<<----- exception
The field color is varchar (firebird) contain values like cllime, clred, etc...
but I get error 'Could not convert variant of type (UnicodeString) into type (Boolean)' at the line with exception comment. what should I change ?
Thanks
I would replace your if statement with the following. It uses the VarIsType function, which is more straight for Variant type checking and it converts string value stored in your Variant variable to color by using the StringToColor function:
...
if VarIsType(gs, [varString, varUString]) then
AStyle.Color := StringToColor(gs);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With