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
ifstatement with the following. It uses theVarIsTypefunction, which is more straight for Variant type checking and it converts string value stored in your Variant variable to color by using theStringToColorfunction: