【问题标题】:How to change the color of TStringGrid grid-lines?如何更改 TStringGrid 网格线的颜色?
【发布时间】:2015-03-22 08:34:35
【问题描述】:

我刚刚完成了从 D7 到 XE2 的迁移,我注意到默认的网格线非常微弱(我喜欢将显示器上的对比度设置为高也无济于事),你可以请参阅下面的屏幕截图:

这是我尝试通过设置TStringGridOnDrawCell 事件将线条重新着色为更暗:

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;

但这会产生更不理想的结果,请特别注意活动单元格的边框:

有什么方法可以让这些网格线变暗或变粗,看起来不像我的尝试那么难看?

【问题讨论】:

  • @JerryDodge 我用谷歌搜索了一个小时,但找不到。这个问题的描述和措辞都很糟糕; StringGrid 的 borders 与单元格的边框不同,这是链接的提问者实际询问的内容。我从这个问题中没有什么可以得到的,但把它留在这里会对未来的 Google 员工有所帮助。
  • 不幸的是,这并没有改变 Stack Overflow 的规则。您发布的问题和答案已经在这里。如果您认为它们的措辞不好,您可能会看到如何增强现有的。

标签: delphi delphi-xe2 vcl tstringgrid


【解决方案1】:

根据this问题的答案,我只是将TStringGridDrawingStyle属性设置为gdsClassic

【讨论】:

    猜你喜欢
    • 2018-10-01
    • 1970-01-01
    • 2011-12-24
    • 2018-02-20
    • 2016-02-21
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多