AdvDBGrid row color removes buttons.

Using current Component packs, Windows 7 64 Pro, Delphi XE7.


Project works as expected and displays the database grid as this link indicates.

https://dl.dropboxusercontent.com/u/101647100/2016-06-29_6-11-10.jpg

I then add code to process an expiration date field that was stored as text, so that I can color the background of the row for the user to identify easily.  The code is in the AdvDBGrid's GetCellColor event.

procedure TForm1.asgEligibleGetCellColor(Sender: TObject; ARow, ACol: Integer;
  AState: TGridDrawState; ABrush: TBrush; AFont: TFont);
var MyMonth, MyDay, MyYear, MyDate, WorkDate : string;
  i : integer;
begin
  if (ACol = 5) and (ARow > 0) and FormShown then
  begin
     MyDate := asgEligible.Cells[ACol,ARow];
     if length(MyDate) > 7 then
     begin
       i := pos('/',MyDate);
       MyMonth := copy(MyDate,0,i-1);
       WorkDate := copy(MyDate,i+1);
       MyDate := WorkDate;
       i := pos('/',MyDate);
       MyDay := copy(MyDate,0,i-1);
       MyYear := copy(MyDate,i+1,4);
       MyDate := MyMonth + '/' + MyDay + '/' + MyYear + ' 00:00:00';
       if StrToDateTime(MyDate) < Now then
         asgEligible.RowColor[ARow] := clRed;
     end;
  end;

FormShown is a global boolean, set true in the Form OnShow event.

The highlighting works, but all the buttons / edits / labels on the rest of the form disappear as seen in this link.

https://dl.dropboxusercontent.com/u/101647100/2016-06-29_6-12-18.jpg

If I comment the line testing the date and setting the row color to clRed, the buttons / edits / labels are OK.

Any clue as to what I am doing wrong?

I am using these components on the form:

    AdvPanel1: TAdvPanel;
    AdvPanel2: TAdvPanel;
    AdvFormStyler1: TAdvFormStyler;
    AdvPanelStyler1: TAdvPanelStyler;
    acbColorScheme: TAdvComboBox;
    WebUpdate1: TWebUpdate;
    ExeInfo1: TExeInfo;
    ADOConnection1: TADOConnection;
    ADOQuery1: TADOQuery;
    User: TAdvEdit;
    UserPW: TAdvEdit;
    ServerIP: TAdvIPEdit;
    afneMSPFile: TAdvFileNameEdit;
    asbLoad: TAdvSmoothButton;
    DataSource1: TDataSource;
    asgEligible: TDBAdvGrid;
    AdvDBFilterDialog1: TAdvDBFilterDialog;


You should not set color related properties from the OnGetCellColor event. The OnGetCellColor event is designed to do the settings via its parameters, i.e. here replace 


asgEligible.RowColor[ARow] := clRed

by

ABrush.Color := clRed;

Using your suggestion, nothing is highlighted.  All expired date rows look exactly like the non-expired ones.

Please see the demo ADOSelColor in the DBSdvGrid samples folder for a sample on how you can dynamically customize cell (or row) appearance

That was my original source.  Also, from the AdvStringGrid manual, page 62, example of setting font color uses the OnGetCellColor routine.  I will look closer at the example programs again, though.

Works perfectly now.  I was confusing the grid.brush with the parameter ABrush.