advstringgrid合并了单元格后怎么实现字体上下居中
答案:2 悬赏:30
解决时间 2021-04-09 23:37
- 提问者网友:萌萌小主
- 2021-04-09 00:11
advstringgrid合并了单元格后怎么实现字体上下居中
最佳答案
- 二级知识专家网友:青春如此荒謬
- 2021-04-09 01:45
点击表格菜单下面的绘制表格菜单,把表格工具栏掉出来,然后点击这个工具栏中的居中方式按钮,选择里面的上下左右居中。
全部回答
- 1楼网友:时光不老我们不分离
- 2021-04-09 02:33
完整的程序源码:
您拷贝就可以运行:
unit unit1;
interface
uses
windows, messages, sysutils, variants, classes, graphics, controls, forms,
dialogs, grids;
type
tform1 = class(tform)
stringgrid1: tstringgrid;
procedure stringgrid1drawcell(sender: tobject; acol, arow: integer;
rect: trect; state: tgriddrawstate);
procedure formcreate(sender: tobject);
private
{ private declarations }
public
{ public declarations }
end;
var
form1: tform1;
implementation
{$r *.dfm}
procedure tform1.stringgrid1drawcell(sender: tobject; acol, arow: integer;
rect: trect; state: tgriddrawstate);
begin
with stringgrid1 do
if cells[acol,arow] = '1233' then
begin
canvas.font.color := clred; //字体颜色为红的
canvas.brush.color:=clmoneygreen; //背景为 美元绿色
canvas.fillrect(rect);
canvas.textout(rect.left+2,rect.top+2,cells[acol,arow]);
end;
end;
procedure tform1.formcreate(sender: tobject);
begin
with stringgrid1 do
begin
rowcount :=5;//设置5行
colcount :=5;//设置5列
cells[1,2]:='1233';
cells[2,2]:='1233';
cells[2,4]:='1233';
end;
end;
end.
-----------------------------------------------------
关键是drawcell事件,在这个事件中可以设字体名、大小、颜色、字体装饰、cell背景画布等
---------------------------------------------------
我要举报
如以上问答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
推荐资讯