TADVStringGrid如何动态更改与当前cellADV相邻的单元格的文本颜色

问题描述 投票:0回答:1

我有一个带有ColorCombo编辑器的Cell,旁边是一个带有一些文本的单元格。我想在ColorCombo编辑器中选择不同颜色时动态更改相邻单元格中文本的颜色。

我还没有找到一种方法来访问相邻单元格的Canvas,所以我可以改变颜色

delphi
1个回答
1
投票

来自TMS Documentation

“单元属性也可以直接设置。使用这种方法当然需要更多的内存,因为属​​性存储在每个单元中。可能的属性是:

property Alignments[Col,Row: Integer]: TAlignment;
property Colors[Col,Row: Integer]: TColor; property ColorsTo[Col,Row: Integer]: TColor;
property FontColors[Col,Row: Integer]: TColor;
property FontStyles[Col,Row: Integer]: TFontStyles;
property FontSizes[Col,Row: Integer]: Integer;
property FontNames[Col,Row: Integer]: string;

示例:将单元格2,3设置为红色背景,粗体Tahoma字体和右对齐

Grid.Colors[2,3] := clRed; 
Grid.FontStyles[2,3] := Grid.FontStyles[2,3] + [fsBold];
Grid.FontNames[2,3] := ‘Tahoma’; 
Grid.Alignments[2,3] := taRightJustify;

注意:属性grid.ColorsTo [Col,Row:Integer]:TColor用于指定单元格中的垂直渐变,从Colors []设置的颜色到ColorsTo []设置的颜色。 “

© www.soinside.com 2019 - 2024. All rights reserved.