关于TStringGrid的问题。 如何让TStringGrid中的内容靠右显示,标题居中显示,并且修改指定的某一行的颜色和字体。 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 在StringGrid的OnDrawCell事件中:procedure TForm1.StringGrid1DrawCell(Sender: TObject; ACol, ARow: Integer; Rect: TRect; State: TGridDrawState);var uFormat: Integer;begin with StringGrid1 do with Canvas do begin FillRect(Rect); if ARow = 0 then uFormat := DT_CENTER+DT_SINGLELINE+DT_VCENTER // 居中 else uFormat := DT_RIGHT+DT_SINGLELINE+DT_VCENTER; // 居右 if ARow = 2 then begin // 如果是第二行则改颜色和字体 Font.Color := clRed; Font.Name := '黑体'; end; DrawText(Handle, PChar(Cells[ACol, ARow]), Length(Cells[ACol, ARow]), Rect, uFormat); end;end; 服务启动失败,错误代码1053,请delphi高手帮忙看看? *.qrp格式的报表要转换成pdf或者其他格式,有现成的工具没有, ★关于VCLZip2.23分卷压缩出现第一个.zip文件不见了的问题??? 如何给TDBGrid显示的数据加上序号? 不知不觉中已上了双星.高兴。 太奇怪了!非高高手不能解决!(分这么少,不好意思) 怎样获得主机的机器名? ADO数据库 客户与 服务器如何连接 怎么在ADOTABLE中将指针定位于符合条件的记录 窗体有ForeActive事件吗?我怎么在event里找不到 (讨论)大家谈谈插件技术啊,像winamp这样的? 换工作了,散分!!
Rect: TRect; State: TGridDrawState);
var uFormat: Integer;
begin
with StringGrid1 do
with Canvas do begin
FillRect(Rect);
if ARow = 0 then
uFormat := DT_CENTER+DT_SINGLELINE+DT_VCENTER // 居中
else
uFormat := DT_RIGHT+DT_SINGLELINE+DT_VCENTER; // 居右
if ARow = 2 then begin // 如果是第二行则改颜色和字体
Font.Color := clRed;
Font.Name := '黑体';
end;
DrawText(Handle, PChar(Cells[ACol, ARow]), Length(Cells[ACol, ARow]),
Rect, uFormat);
end;
end;