Jump to content
Dave Craggs

Stringgrid cell color

Recommended Posts

This should be a basic question, but I am trying to draw the colour of a cell in a stringrid

 

            grdDetails.Canvas.Font.Style := [fsBold];
            grdDetails.Canvas.Brush.Color := clSilver;
            grdDetails.Canvas.TextRect(Rect, Rect.Left, Rect.Top+4, 'Test Header');

 

But I am getting this

 

image.png.e95c2a76cb939148b42a365aad0866c3.png

 

Note the cell is not fully coloured.

 

Any ideas on what I am doing wrong?

  • Like 1

Share this post


Link to post

Vcl.Grids.pas

 

if DefaultDrawing then
  begin
    if StyleServices.Enabled then
    begin
      ARect.Left := ARect.Left + 4;

 

I can't tell you why.

 

Edit: See below. It's the DefaultDrawing property.

 

 

 

Edited by Attila Kovacs

Share this post


Link to post

I don't work with Stringgrid. But based on my experience and picture:
The cell is stained from the text. It means only one thing. There is some space defined in front of the text. Probably an indentation of the text. Check it out.

Share this post


Link to post

You could perhaps do a grdDetails.Canvas.FillRect(Rect) before calling TextRect?

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×