如何设置字体颜色,字体样式和背景颜色为ListView.Item.Caption
?我的代码,你可以看到下面的图像,是行不通的。
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;
2条答案
按热度按时间vlju58qv1#
OnCustomDrawSubItem()
只绘制子项目。请使用OnCustomDrawItem()
来绘制项目。0yycz8jy2#
下面是为单个Subitem单元格着色的方法:(在我的例子中,子项Nr 4的数据必须大于零,而子项必须是Nr 5。在每个单元格绘制后,你必须再次将颜色设置为clblack。
Picture with listview and colored cells