Hello,
you are right, by default color is stored as ColorName (Red, Blue..) or as RGB value ($00C86CD2) by rDBGrid,
But you can use Field events GetText and SetText to convert string values to integer value by one line of code:
uses rpictool;
procedure TDMData.MyFieldGetText(Sender: TField; var Text: string;
DisplayText: Boolean);
begin
Text:=ColorToString(Sender.AsInteger);
end;
procedure TDMData.
MyFieldSetText(Sender: TField; const Text: string);
begin
Sender.AsInteger:=StringToColor(Text);
end;
Then it will work also with integer field.
There is also small issue with selection of custom color with integer field in the current version which can be easily fixed and will be available in the next version.
In meantime you can update rDBGrid source manually as follows, just replace whole function:
function TrDBGridInplaceEditEx.CheckSelectUserDefinedColor(F: TField): boolean;
var
Dlg: TColorDialog;
userDefColor: boolean;
begin
Result:=false;
if F is TNumericField then
userDefColor:=rpictool.GetColorIdx(F.AsInteger) = ColorDefCustomIdx
else
userDefColor:=rpictool.GetColorIdx(F.AsString) = ColorDefCustomIdx;
if userDefColor then
begin
Dlg:=TColorDialog.Create(self);
Dlg.Color:=rpictool.StringToColor(oldFieldColorString);
Dlg.Options:=[cdFullOpen, cdAnyColor];
try
if Dlg.Execute(Handle) then
begin
if F is TNumericField then
F.AsInteger:=Dlg.Color
else
F.AsString:='$' + IntToHex(ColorToRGB(Dlg.Color), 8);
Result:=true;
end
else
F.AsString:=oldFieldColorString;
finally
FreeAndNil(Dlg);
end;
end;
end;
I hope it helps.
Tomas