stringgrid 字的颜色设置的问题
每格怎么设置字的颜色?
每格的背景色怎么获取?本人想实现的是:在编辑时把字的颜色设成看的见的,非编辑装态时,字的颜色与背景色相同,即看不见.求教!
每格怎么设置字的颜色?
每格的背景色怎么获取?本人想实现的是:在编辑时把字的颜色设成看的见的,非编辑装态时,字的颜色与背景色相同,即看不见.求教!
解决方案 »
- [在线等]--怎么样自己创建组件
- 新手要做B/S结构的管理系统,请大家给点建议
- 菜,菜,,菜,,,,,,,
- 自动投票与动态IP
- 如何获得密码框里记住的密码,让*还原成明码?
- 一个小问题
- [高手请进] 用THTTPRIO访问Web Service服务器,当需要username与password时,THTTPRIO该怎么用呢?
- visibroker smart agent
- 请问如何使用DELPHI调用ACD2000的文件?给50
- To:千两狂死郎::Fastreport控件如何安装???
- 做三层架构,有几个API函数不懂,看win32帮助半懂半不懂的,请帮忙看看
- 函数地址的小问题(很简单 在线等)
red,green,blue:byte;
begin
Red:=Byte(StringGrid1.Canvas.Brush.Color);
Green:=Byte(rgb shr 8);
Blue:=Byte(rgb shr 16);
end;
比如:
procedure TForm1.FormShow(Sender: TObject);
begin
StringGrid1.Cells[0,0]:='我';
StringGrid1.Cells[1,0]:='爱';
StringGrid1.Cells[2,0]:='中';
StringGrid1.Cells[3,0]:='国';
end;procedure TForm1.StringGrid1DrawCell(Sender: TObject; ACol, ARow: Integer;
Rect: TRect; State: TGridDrawState);
var
sText: String;
begin
sText:=StringGrid1.Cells[ACol,ARow];
StringGrid1.Canvas.Font.Name:='宋体';
StringGrid1.Canvas.Font.Size:=11;
if ACol=0 then
StringGrid1.Canvas.Font.Color:=clRed;
if ACol=1 then
StringGrid1.Canvas.Font.Color:=clBlue;
if ACol=2 then
StringGrid1.Canvas.Font.Color:=clYellow;
StringGrid1.Canvas.TextOut(Rect.Left,Rect.Top,sText);end;
自己用代码控制需要改变颜色的地方
StringGrid1.Canvas.Brush.Color:= clwhite;
StringGrid1.Canvas.FillRect(Rect);
if (StringGrid1.Col = ACol) and (StringGrid1.Row = ARow) then
StringGrid1.Canvas.Font.Color:= clblack
else
StringGrid1.Canvas.Font.Color:= clblue;
StringGrid1.Canvas.TextOut(Rect.Left + 2, Rect.Right + 2, StringGrid1.Cells[ACol, ARow]);