【问题标题】:Change the color of text in a particular dxStatusBar1.Panel更改特定 dxStatusBar1.Panel 中文本的颜色
【发布时间】:2014-11-05 23:37:00
【问题描述】:

如何更改特定 dxStatusBar1.Panel 的文本颜色? dxStatusBar 是 Devexpress 的 VCL 组件。

【问题讨论】:

  • 那是7年前的事了!?
  • 是的,这应该使它更加相关,这是对这种能力的 7 年的补充。还有为什么我不只是把它作为答案。郑重声明,我从未使用过 DevExpress。
  • 唯一重要的是多久以前写的东西是当你尝试它并且它不再有效时。您是否尝试过@Jerry 提供的链接中的信息?
  • 是的,但这没什么区别。使用皮肤控制器只是改变皮肤。文字保持不变。

标签: delphi devexpress delphi-xe7


【解决方案1】:

面板有一个 OnDrawPanel 事件。可能最简单的方法是挂钩该事件,然后按照您希望的方式绘制面板。像这样的:

procedure TFormTest.dxStatusBar1Panels1DrawPanel(Sender: TdxStatusBarPanel;
    ACanvas: TcxCanvas; const ARect: TRect; var ADone: Boolean);
begin
  Sender.PanelStyle.Painter.FillBackground(dxStatusBar1, Sender, ACanvas, ARect);
  ACanvas.Font.Color := clBlue;
  ACanvas.DrawText(Sender.Text, ARect, cxSingleLine or cxAlignVCenter or cxAlignLeft);
  ADone := True;
end;

您应该添加一些检查以确保实际分配了画家,并且在未分配的情况下,您需要自己绘制背景。

以下是输出示例。

【讨论】:

  • 我认为这样可以为整个状态栏更改它。与使用皮肤相同。
  • @user3927897 这是特定面板的 OnDrawPanel 事件,而不是整个状态栏。
【解决方案2】:

最简单的方法:

dxStatusBar1.Panels[0].PanelStyle.Font.Color :=clRed;

【讨论】:

    猜你喜欢
    • 2016-02-02
    • 2012-03-13
    • 2017-12-31
    • 1970-01-01
    • 2018-04-29
    • 2013-04-17
    • 2012-06-16
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多