gpt4 book ai didi

delphi - 将字体颜色、字体样式和背景颜色设置为ListView.Item.Caption

转载 作者:行者123 更新时间:2023-12-01 17:56:19 30 4
gpt4 key购买 nike

如何设置ListView.Item.Caption的字体颜色、字体样式和背景颜色?我的代码(如下图所示)无法正常工作。

Image

procedure TFMainForm.ListView1CustomDrawSubItem(Sender: TCustomListView;
Item: TListItem; SubItem: Integer; State: TCustomDrawState;
var DefaultDraw: Boolean);
begin
case SubItem of
0:
begin
Sender.Canvas.Brush.Color := clLime;
Sender.Canvas.Font.Color := clBlack;
Sender.Canvas.Font.Style := [FsBOld];
end;
1:
begin
Sender.Canvas.Brush.Color := clLime;
Sender.Canvas.Font.Color := clBlack;
Sender.Canvas.Font.Style := [FsBOld];
end;
2:
begin
Sender.Canvas.Font.Color := clBlack;
Sender.Canvas.Font.Style := [FsBOld];
end;
3:
begin
Sender.Canvas.Font.Color := clBlack;
Sender.Canvas.Font.Style := [FsBOld];
end;
4:
begin
Sender.Canvas.Font.Color := clBlack;
Sender.Canvas.Font.Style := [FsBOld];
end;
end;
end;

最佳答案

OnCustomDrawSubItem() 仅绘制子项。使用 OnCustomDrawItem() 绘制项目。

procedure TForm24.ListView1CustomDrawItem(Sender: TCustomListView;
Item: TListItem; State: TCustomDrawState; var DefaultDraw: Boolean);
begin
Sender.Canvas.Brush.Color := clLime;
end;

procedure TForm24.ListView1CustomDrawSubItem(Sender: TCustomListView;
Item: TListItem; SubItem: Integer; State: TCustomDrawState;
var DefaultDraw: Boolean);
begin
Sender.Canvas.Brush.Color := clYellow;
end;

enter image description here

关于delphi - 将字体颜色、字体样式和背景颜色设置为ListView.Item.Caption,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48236278/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com