Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / lazarus / 2011-08

Handling of states in TStringGrid when using custom drawing of cells

1 message · 1 person ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Eirik Nesje

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).

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus.freepascal.org/pipermail/lazarus/attachments/20110814/7903e46a/attachment.html>

Reply by email