DrawColumnCell

Any word on this ? I need to know if this is a problem with a property of the grid or otherwise. Or if this is perhaps a bug of some kind. I need to use this scenario in other places and dont want to be worried about work arounds. Your assistance is appreciated.

Eddie

Tim there are NO BLANK records in the dataset. The Blank row is being created by the scrolling and moving and redraw of the TDBADVGrid by the component somehow. I already wrote a workaround to check for that but there is obviously a problem with the component or a particular setting in the component that causes this when the navigation reaches the bottom of the visual portion of the dataset after the initial drawing has been completed successfully.. I also added to check if Row number > 0. There should not be any other blank rows of data at any point other than initial drawing that includes the header row and that is being accounted for like I just said.

  1. For a partially visible row in the grid, the data from the dataset isn't loaded but the cell still needs to be (partially) drawn. This can lead to a blank value for the cell when OnGetCellColor is triggered.

  2. Your code is not efficient. For code in drawing routines, efficiency is crucial. Minimize the string to integer conversions needed.

A much more efficient way is:

procedure TForm1.DBAdvGrid1GetCellColor(Sender: TObject; ARow,
  ACol: Integer; AState: TGridDrawState; ABrush: TBrush; AFont: TFont);
var
  val8,val9,val10: integer;
begin
  if (ARow > 0) and (ACol in  [8,9,10]) then
  begin
    val8 := DBAdvGrid1.Ints[8, ARow];
    val9 := DBAdvGrid1.Ints[9, ARow];
    val10 := DBAdvGrid1.Ints[10, ARow];

    if Acol = 9 then
    begin
      if (val9 = val10) then
        ABrush.Color:= clAqua
      else
        ABrush.Color:= clWhite
    end
    else
    if Acol = 10 then
    begin
      if (val9 = val10) then
        ABrush.Color := clMoneyGreen
      else
        ABrush.Color:= clGray
    end
    else
    if Acol = 8 then
    begin
      if val8 >= 0 then
      begin
        if val8 = 0 then
          ABrush.Color:= clRed
       else
         ABrush.Color:= clWhite
       end;
    end;
  end;
end;

Thanks Bruno, ok understood on the issue with the redraw and possible blank cell.

Yes the code is inefficient because I was trying to figure out what was causing the error and that is why I split it up that way. At first I thought it was a specific column. I was definitely going to streamline but you saved me the time, Thank you !!..

Question: by using grid.ints instead of the grid.cells(r,c].ToInteger the error with the '' cell does not occur. Could you tell me why that is ? Just want to know for knowledge as I will be using these grids much more. With the code above you do not check for the '' as I had to with mine. Would like to know why.

Everything working perfectly now regardless. As always the support and help is greatly appreciated !!! I am about to purchase the full TMS in the next couple of days, love your products but even more love the support !!!

Eddie

grid.Ints[col,row]: integer will return zero when the cell contains non-numeric data.