Jump to content

StringGrid cell style not working.


rgreat

Recommended Posts

I managed to design this grid, but I can not set cell text alignment.

image.png.f488d396d1d81df41c2cc191181352ce.png

I cannot seems to currectly use Attribs.Style SG0DrawCell event.

procedure TMain.SG0DrawCell(Sender: TObject; ACol, ARow: Integer; var Value: string; Attribs: TUniCellAttribs);
begin
  Attribs.Font.Size:=10;
  Attribs.Font.Style:=[fsBold];

  if ARow=0 then begin
    Attribs.Font.Color:=clBlack;
  end else begin
    if ACol=0 then begin
      Attribs.Font.Color:=rgb(0,32,96);
      Attribs.Color:=rgb(152,152,152);
    end else begin
      Attribs.Font.Color:=clBlack;
      Attribs.Color:=rgb(213,213,213);
    end;
    Attribs.Style.Style := 'text-align: center;'; // <- this like breaks all previous settings and does not seems to do anything itself.
  end;

Can someone give out example of setting cell styles through OnDrawCell event?

I would also like to know how to disable cell selection rectangle drawing.

Link to comment
Share on other sites

2 minutes ago, rgreat said:

I managed to design this grid

Hello,

By the way, a very good design.

3 minutes ago, rgreat said:

this like breaks all previous settings and does not seems to do anything itself.

I will check.

  • Like 1
Link to comment
Share on other sites

Workaround for someone who might be interested:

.mygrid div table td div{
    text-align: center !important;
}

.mygrid div table td:nth-child(1) div{
    text-align: left !important;
}

.mygrid div table:nth-child(1)  td div{
    text-align: center !important;
}

.mygrid div table:nth-child(2)  td:nth-child(1) div{
    text-align: right !important;
}

And set  grid LayoutConfig.Cls to 'mygrid'.

image.png.d4edafb91d5271a0a241009f509d73b1.png

  • Like 1
Link to comment
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
×
×
  • Create New...