关于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; 如何通过TRACKBAR调节图像亮度与对比度 求一行代码 求如何改变输入时闪动的光标形状? Delphi的问题,各位高手请指教,感激不尽! 自定义组件问题 问一个特菜的问题(Delphi基础) 急!D7的建立Corba对象的向导无法执行是什么原因? 急求卡拉ok播放系统开发的资料!~ dephi 安装字体文件到XP和WIN7系统均不成功?,求高手指点! “在Win2000中调用DLL要以调用句柄的方式调用”是什么意思? (讨论)大家谈谈插件技术啊,像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;