Hi, Ik gebruik de vcl.styles in Delphi XE7. Op zich werkt dit goed.
Ik heb echter een probleem in de TClientdatasetGrid, wanneer de rij geselecteerd is.
b.v. Als de waarde in een cell = 'T' (of true), dan wil ik graag een ? tonen.
Zo ook: Als een getal of bedrag negatief is, dan toon ik deze in het rood maar ook met de '--' achter het getal i.p.v. ervoor.
Dus -123,25 wordt getoond als 123,25-- (rood)
Dit gebeurt in een procedure, die wordt aangeroepen vanuit de dbgListDrawColumnCell.

code: in dbgListDrawColumnCell(…)
Canvas.FillRect(rect);
if b = ‘U’
then begin
x := (Rect.Left + Rect.Right – ilstGridIcons.Width) div 2;
y := (Rect.Top + Rect.Bottom – ilstGridIcons.Height) div 2;
ilstGridIcons.draw(Canvas, x, y, 2);

en

function Field2Text(const f : TNumericField): string;
begin
result := Trim(f.DisplayText);
if result <> ''
then begin
if result[1] = '-'
then result := copy(result,2, 100) + '--'
else result := result + ' ';
end;
end;

Dit werkte goed in de oudere Delphi versies (Delphi 2006/2007/2010) maar als ik nu een andere style kies,
dan wordt in de geselecteerde rij zowel een ? en een T getoond (Is de rij niet geselecteerd, dan wordt de juiste waarde getoond)
Zo ook -123,25 en 123,25-- in dezelfde cell. Dus door elkaar!
Wie weet hoe ik dit kan oplossen?


code: (in dbgListDrawColumnCell(…)
var
s : string;
x, y : integer;
c : TColumn;
b : TBrushStyle;
begin
c := Column;

if (Column.Field is TNumericField)
then begin
if (gdSelected in State)
then begin
b := dbglist.canvas.Brush.style;
dbglist.canvas.Brush.style := bsSolid;
x := Rect.Right;
y := Rect.Top;
dbgList.Canvas.TextRect(Rect, x, y, ' ');
dbglist.canvas.Brush.style := b;
end;

s := Field2Text(Column.field as TNumericField);

if RightStr(s,2) = '--'
then begin
if dbgList.Canvas.Brush.Color <> clRed
then dbgList.Canvas.Font.Color := clRed
else dbgList.Canvas.Font.Color := clWindow;

dbgList.Canvas.Font.Style := [fsbold]
end
else dbgList.Canvas.Font.Style := [];

x := Rect.Right - dbgList.Canvas.TextWidth(s) - 2; // 2 pixels ruimte
y := (Rect.Top + Rect.Bottom - dbgList.Canvas.TextHeight(s)) div 2 ;

dbgList.Canvas.TextRect(Rect, x, y, s);

end
else if (Column.Field is TCurrencyField)
then begin
s := Field1Text(Column.field as TCurrencyField);

if RightStr(s,2) = '--'
then begin
if dbgList.Canvas.Brush.Color <> clRed
then dbgList.Canvas.Font.Color := clRed
else dbgList.Canvas.Font.Color := clWindow;

dbgList.Canvas.Font.Style := [fsbold]
end
else dbgList.Canvas.Font.Style := [];

x := Rect.Right - dbgList.Canvas.TextWidth(s) - 2; // 2 pixels ruimte
y := (Rect.Top + Rect.Bottom - dbgList.Canvas.TextHeight(s)) div 2 ;
dbgList.Canvas.TextRect(Rect, x, y, s);

end
else if (Column.Field is TFloatField)
then begin
s := Field3Text(Column.field as TFloatField);

if RightStr(s,2) = '--'
then begin
if dbgList.Canvas.Brush.Color <> clRed
then dbgList.Canvas.Font.Color := clRed
else dbgList.Canvas.Font.Color := clWindow;

dbgList.Canvas.Font.Style := [fsbold]
end
else dbgList.Canvas.Font.Style := [];

x := Rect.Right - dbgList.Canvas.TextWidth(s) - 2; // 2 pixels ruimte
y := (Rect.Top + Rect.Bottom - dbgList.Canvas.TextHeight(s)) div 2 ;
dbgList.Canvas.TextRect(Rect, x, y, s);

end
else if (Column.Field is TStringField) and (Column.Field.Tag = 1)
then begin
if (Column.Field.Tag = 1) and (Column.Field.Size = 1)
then DrawBooleanCell(dbgList.Canvas, Rect, (Column.Field.AsString+'?')[1] = 'T');
end
else if column.Field is TBooleanField
then begin
DrawBooleanCell(dbgList.Canvas, Rect, (Column.Field as TBooleanField).value);
end
//MDA 2010-10 pijlen toegevoegd Buji-006 07-12-2010 Aanpassing MJD Overgenomen
else if (Column.Field is TStringField) and (Column.Field.Tag = 2)
then begin
if (Column.Field.Size = 1)
then DrawBooleanCell2(dbgList.Canvas, Rect, (Column.Field.AsString));
if (Column.Field.Size = 3)
then DrawBooleanCell3(dbgList.Canvas, Rect, (Column.Field.AsString));
if (Column.Field.Size = 4)
then DrawBooleanCell4(dbgList.Canvas, Rect, (Column.Field.AsString));
end
else dbglist.DefaultDrawColumnCell(Rect, DataCol, c, State);

end;