zoukankan      html  css  js  c++  java
  • 启用 TStringGrid 的自画功能,并避免重影

    FMX 控件的 TStringGrid 下,有时为了让不同行或不同 Cell 的显示颜色、字体等有各种不同的颜色, 必须采用自画, 即在其 OnDrawColumnCell 事件中写自己的控制代码显示。

    例如:

        s := sgrdLog.Cells[1,Row];
    
        if s = 'info' then
          Canvas.Fill.Color := ccbInfo.Color
        else if s = 'error' then
          Canvas.Fill.Color := ccbError.Color
        else if s = 'warn' then
          Canvas.Fill.Color := ccbWarning.Color
        else if s = 'debug' then
          Canvas.Fill.Color := ccbDebug.Color
        else if s = 'trace' then
          Canvas.Fill.Color := ccbTrace.Color
        else if s = 'fatal' then
          Canvas.Fill.Color := ccbFatal.Color
        else
          Canvas.Fill.Color := TAlphaColorRec.Black;
    
        Canvas.FillText( Bounds, Value.ToString, False, 1, [], TTextAlign.Leading );

    但显示效果你会发现有重影, 有个默认的黑色字体在后面,效果很差。 要解决这个问题很简单, 在程序启动后增加一句即可:

      sgrdLog.DefaultDrawing := False;
  • 相关阅读:
    10.31JS日记
    10.24JS日记
    10.23JS日记
    10.22JS日记
    10.19JS日记
    10.18JS日记
    Tomcat—Bad Request
    2016年上半年总结
    线程间操作无效
    压缩字符串的函数
  • 原文地址:https://www.cnblogs.com/zhenfei/p/4586544.html
Copyright © 2011-2022 走看看