Dan Kelly
Dan Kelly

Reputation: 2702

How to format StringGrid cell borders

I am trying to format a Delphi TStringgrid depending on cell contents and position.

Whilst I can change the cell colour and shape depending on the cell contents I am having more problems with the cell borders.

I want to be able to have a thicker cell border on one side or the other every n columns

Any pointers?

Cheers

Dan

Upvotes: 3

Views: 3846

Answers (2)

Svetoslav Trifonov
Svetoslav Trifonov

Reputation: 1

For cell borders just use for example DrawRect(TrectF,0,0,[],1,TStrokeBrush) with same TrectF that you used for FillRect...

If you want different borders on different sides use draw

Canvas.DrawLine(Tpointf.Create(Column.Position.X,row * StrGrid.RowHeight),TPointF.Create(column.Width,row * StrGrid.RowHeight),1,Brush);

I hope this helps.

Upvotes: 0

Remy Lebeau
Remy Lebeau

Reputation: 595742

Simply extend the bounds of the TRect that you are drawing in. Just because the OnDrawCell event gives you a particular TRect does not mean you are limited to just those coordinates. You have access to the entire grid's UI to draw on. So simply draw extra lines where you need them.

Upvotes: 4

Related Questions