I am trying to format a Delphi TStringgrid depending on cell 开发者_如何学Gocontents 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
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.
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.
精彩评论