如何让Stringgrid中的单元格的内容显示换行?

ray666 2004-09-16 04:29:53
如何让Stringgrid中的单元格的内容显示换行?
...全文
204 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
ray666 2004-09-16
  • 打赏
  • 举报
回复
to: xiaoxiao197821
就是要这个效果!
thanks! everyone
luke5678 2004-09-16
  • 打赏
  • 举报
回复
//自动换行
procedure TForm1.StringGrid1DrawCell(Sender: TObject; ACol, ARow: Integer;
Rect: TRect; State: TGridDrawState);
begin
DrawText(StringGrid1.Canvas.Handle,pchar(StringGrid1.Cells[Acol,Arow]),Length(StringGrid1.Cells[Acol,Arow]),Rect,DT_WORDBREAK or DT_LEFT);
end;
xiaoxiao197821 2004-09-16
  • 打赏
  • 举报
回复
procedure TForm1.StringGrid1DrawCell(Sender: TObject; ACol, ARow: Integer;
Rect: TRect; State: TGridDrawState);
begin
if (ACol = 1) and (ARow = 1) then
begin
StringGrid1.Canvas.Font.Size := 8;
StringGrid1.Canvas.TextOut(rect.Left+8,rect.Top,'str1');
StringGrid1.Canvas.TextOut(rect.Left+8,rect.Top + 11,'str2');
end;
end;

5,392

社区成员

发帖
与我相关
我的任务
社区描述
Delphi 开发及应用
社区管理员
  • VCL组件开发及应用社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧