TStringGrid Borders Help Request

I have what is probably a simple issue, I want to change the color or a border in a TStringGrid. I have choosen a background color for some cells that are the same as the border. Changing DrawingStyle or StyleElements values gives me white borders which is undesirable. Thanks In advance

I use the TMS string grids which have a lot of options.

For the standard grid you could maybe use the OnDrawCell event to draw what you need?

What version of Delphi are you using? StyleElements only comes into play when you are using VCL Styles - which is something I would avoid (as someone that has used them for a long time, regretably).

TMS Advanced String Grid is the third party component I have used most extensively and I find it great.

You have stumbled across its major problem - the number of options available.

I still cut and past my grids from my original sample project so I do not have to cope with choosing all the options.

You need to consult the TMS Documentation

http://tmssoftware.biz/Download/Manuals/TMS%20TAdvStringGrid%20Developers%20Guide.pdf

Is the example I found on line. I had two references in the past but cannot find my copies.

Sorry showing my bias. The question related to the standard string grid

Using ver 11.3 and am turning off styling in general. Been trying OnDrawCell but that has impacts further down and reluctant at this point to use it if I don’t have too.

Just did a quick experiment. Maybe the following code might help. You just need to have a couple of form variables to store the previous column and row numbers.

procedure TForm1.StringGrid1SelectCell(Sender: TObject; ACol, ARow: Integer;
var CanSelect: Boolean);
var
Rect : TRect;
begin
if ((FLastRow <> ARow) or (FLastCol <> ACol)) then begin
Rect := StringGrid1.CellRect(FLastcol, FLastRow);
StringGrid1.Canvas.Brush.Style := bsClear;

StringGrid1.Canvas.Rectangle(Rect.Left - 2,Rect.Top - 2,
        Rect.Right +2 ,Rect.Bottom+ 2 );

end;

Rect := StringGrid1.CellRect(Acol, aRow);
StringGrid1.Canvas.Pen.Color := clRed;
StringGrid1.Canvas.Brush.Style := bsClear;

StringGrid1.Canvas.Rectangle(Rect.Left - 2,Rect.Top - 2,
Rect.Right +2 ,Rect.Bottom+ 2 );
StringGrid1.Canvas.Brush.Style := bsSolid;

//Update the last row and col. Next time we are in this procedure we need to
//reset the colour for the border of the previous cell
FlastRow := ARow;
FLastCol := ACol;
end;