社区
Delphi
帖子详情
再次请教StringGrid的问题,请各位高人指教!
xiaofeng_cxy
2002-08-16 03:11:33
如何画StringGrid的网格线及如何使StringGrid的固定列以居中显示!?
我在线恭候!
...全文
30
6
打赏
收藏
微信扫一扫
点击复制链接
分享
下载分享明细
分享
举报
写回复
6 条
回复
切换为时间正序
当前发帖距今超过3年,不再开放新的回复
发表回复
dupenf
2002-08-18
procedure TForm2.StringGrid1DrawCell(Sender: TObject; ACol, ARow: Integer;
Rect: TRect; State: TGridDrawState);
var
Txt:String;
begin
Txt:=StringGrid1.Cells[ACol,ARow];
StringGrid1.Canvas.Rectangle(Rect);
DrawText(StringGrid1.Canvas.Handle,
Pchar(Txt),
Length(Txt),
Rect,
DT_CENTER or DT_VCENTER );
//在StringGrid单元格画内画字符串
end;
打赏
举报
回复
赞
blazingfire
2002-08-16
我来给你回答,首先你去看下一个API函数:DrawText(...),要StringGrid1的第一列居中显示可以在OnDrawCell事件中写这样代码:
procedure TForm1.StringGrid1DrawCell(Sender: TObject; ACol, ARow: Integer;
Rect: TRect; State: TGridDrawState);
var
value:String;
begin
if ACol=0 then
begin
StringGrid1.Canvas.Brush.Color:=clWhite;
StringGrid1.Canvas.Pen.Color :=clWhite;
StringGrid1.Canvas.Rectangle(Rect);
StringGrid1.Canvas.Font.Color:=clBlue;
value:=StringGrid1.Cells[ACol,ARow];
DrawText(StringGrid1.Canvas.Handle,
Pchar(value),
Length(value),
Rect,
DT_Center or DT_VCenter);//DT_Center为横着居中显示
//DT_VCenter为坚着居中显示
end;
end;
打赏
举报
回复
赞
DBcode
2002-08-16
cai
打赏
举报
回复
赞
gaoys1979
2002-08-16
既然是自己画,不是可以得到Rect吗? 用canvas.lineto canvas.move 设置点画线。。。固定列居中显示?可能要自己判断把它画在中间了。
打赏
举报
回复
赞
findcsdn
2002-08-16
为了能够设置对齐方式我用 TStringAlignGrid,网上下有源码。
为了能够作表格合并我用 TAdvStringGrid,网上下无源码。
打赏
举报
回复
赞
xiaofeng_cxy
2002-08-16
怎么没人回答呢?
高手都上哪去了?
打赏
举报
回复
赞
相关推荐
C++ Builder之
String
Grid
表格简单示例.rar
C++ Builder之
String
Grid
表格简单示例,T
String
Grid
控件使用实例例子
delphi连接mysql速度慢_我用的是
string
grid
连接数据库!关于提高性能的
问题
我有上万条的记录由于实际需要需要用到
string
grid
控件!然而每次往里面添加纪录的时候都非常慢!...
请
高人
指点!分页来做吧~~~否则真的太辛苦了让记录在
String
Grid
中分页显示在Uses中加入: ADOInt//首先设...
Delphi / XE10
String
Grid
实现合并单元格效果显示
在
String
Grid
控件中实现显示Excel形式的合并单元格效果,也可以用Adv
String
Grid
,XL
GRID
等第三方控件,不过要破解比较麻烦。 原理是通过重载 OnDrawCell 事件procedure TForm1.SGDrawCell(Sender: TObject; ACol, ...
C++ builder6 删除选中的
String
Grid
行
软件使用C++ builder6。删除选中的
String
Grid
行。序号不随删除而变化。如果需要变化,则将第一列的字符转化为数字后-1。
Delphi7
String
Grid
内动态添加ComBoBox的值
在
String
Grid
内指定列调出Combobox并给
Grid
赋值
发帖
Delphi
微信扫一扫
点击复制链接
分享社区
下载分享明细
5124
社区成员
26.2w+
社区内容
Delphi 开发及应用
社区管理员
加入社区
帖子事件
创建了帖子
2002-08-16 03:11
社区公告
暂无公告