0
votes

I've just finished migrating from D7 to XE2 and I've noticed that the default grid-lines are extremely faint (it doesn't help that I like to set the contrast on my monitor to high), as you can see in the screenshot below:

Default TStringGrid grid-lines

This was my attempt to re-color the lines darker by setting the TStringGrid's OnDrawCell event:

procedure TfrmBaseRamEditor.DrawStrGrid(Sender: TObject; ACol, ARow: Integer;
                                        Rect: TRect; State: TGridDrawState);
begin
    sgrSenden.Canvas.Pen.Color := clDkGray;
    // "Set the Style property to bsClear to eliminate flicker when the object
    // repaints" (I don't know if this helps).
    sgrSenden.Canvas.Brush.Style := bsClear;
    // Draw a line from the cell's top-right to its bottom-right:
    sgrSenden.Canvas.MoveTo(Rect.Right, Rect.Top);
    sgrSenden.Canvas.LineTo(Rect.Right, Rect.Bottom);
    // Make the horizontal line.
    sgrSenden.Canvas.LineTo(Rect.Left, Rect.Bottom);
    // The other vertical line.
    sgrSenden.Canvas.LineTo(Rect.Left, Rect.Top);
end;

But this produces a result even less desirable, notice especially the border of the active cell:

attempt to modify gridlines

Is there any way to make these grid-lines darker or thicker in a way that doesn't look as ugly as my attempt?

1
@JerryDodge I Googled for an hour and couldn't find it. That question is described and worded badly; the borders of a StringGrid are different from the borders of a cell, which is what the linked questioner was actually asking about. I have nothing more to gain from this question, but to leave it here will do service to future Googlers.DBedrenko
Unfortunately that doesn't change the rules of Stack Overflow. The question and answer that you posted are already here. If you think they're worded badly, you may see how you can enhance the existing ones.Jerry Dodge

1 Answers

2
votes

As per the answer to this question, I simply set DrawingStyle property of the TStringGrid to gdsClassic.