Hi

I have a TStringGrid where I have set up my own OnDrawCell handling. In this new OnDrawCell function I have set up to change behaviour if aCol is 1 and aRow is larger than 0. If not in selected range I call the TStringGrid(Sender).DefaultDrawCell function.

This seems to be working well excepts for that it does not react to changes in the state (specific selected). All cells that are drawn are just displayed with their text values and no indication if they are selected or not. The properties I have set are :

DefaultDrawing = False
Options.RowSelect = True

and OnDrawCell.

The overriden OnDrawCell function is (nothing fancy, just to test) :

procedure TForm1.StringGrid1DrawCell(Sender: TObject; aCol, aRow: integer;
  aRect: TRect; aState: TGridDrawState);
begin
  if (aCol = 1) and (aRow > 0) then
  begin
    TStringGrid(Sender).Canvas.Pen.Color := clRed;
    TStringGrid(Sender).Canvas.Line(aRect);
  end
  else
    TStringGrid(Sender).DefaultDrawCell(aCol, aRow, aRect, aState);
end;

I can implement gdSelectedin my code to handle the columns where I have decided to custom draw the content but should not the DefaultDrawCell function ensure that all the other cells where properly drawn (not just the content but also the state if selected) ?

BR
Eirik

(I'm using Lazarus 0.9.30 on Ubuntu and Lazarus 0.9.31 on Windows. Both displays the same result).

--
_______________________________________________
Lazarus mailing list
[email protected]
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus

Reply via email to