请问如何在改变stringgrid中的文字颜色,要每个CElls都不一样的,因为我要做一个股票软件,里面涨跌都要用不同的颜色显示!我用stringgrid做得接收!
解决方案 »
- 问两个关于TWebBrowser的问题:
- 请教一个文件的复制粘贴问题
- ★★拙作《Delphi精要》及其所属“Borland大系”其他部分书籍已经开始在搜狐连载,有需要可以去看看
- 请问关于delphi窗体信息是否能够转成xml格式来存储
- 第三方控件!!
- 轻松拿分,在线给分!
- 怎么左边打印主表的一条记录,右边对应打印从表的多条记录;然后下一个继续?
- EnumWindows为什么总是逆序查找子窗口?如何让它正序查找
- 哪位大知道ReportBuilder控件的预览怎么调用?先谢过了
- delphi中的组件与ActiveX控件有何区别?
- 打印问题。
- 谁有U ARE U 2000 指纹识别仪的OCX控件或DLL调用库?
procedure TForm1.StringGrid1DrawCell(Sender: TObject; ACol, ARow: Integer;
Rect: TRect; State: TGridDrawState);
begin
with StringGrid1.Canvas do begin
// 根据各种条件设置颜色
if (ACol = 1) and (ARow = 2) then
Font.Color := clBlue
else
if (ACol = 2) and (ARow = 1) then
Font.Color := clRed;
TextOut(Rect.Left+2, Rect.Top+2, StringGrid1.Cells[ACol, ARow]);
end;
end;
procedure TForm1.StringGrid1DrawCell(Sender: TObject; ACol, ARow: Integer;
Rect: TRect; State: TGridDrawState);
begin
if gdFixed in state then Exit;
If StringGrid1.Cells[ACol,ARow]='A' then
stringgrid1.Canvas.Font.Color:=clBlue
else
stringgrid1.Canvas.Font.Color:=clRed;
stringgrid1.Canvas.Font.Height:=16;
stringgrid1.Canvas.Font.Style:=[fsBold];
stringgrid1.canvas.textout(rect.left+3,rect.top+6,StringGrid1.Cells[ACol,ARow]);
end;