*********************************
表头居中显示-正确写法
————
private sub drawergrid()
with mshflexgrid1
.backcolor = &hffc0c0
.backcolorsel = &hc0e0ff
.forecolor = &hc00000
.forecolorsel = &hc00000
.cols = 6
.rows = 2
.colwidth(0) = 500
.colwidth(1) = 600
.colwidth(2) = 1700
.colwidth(3) = 900
.colwidth(4) = 600
.colwidth(5) = 700
.textmatrix(0, 0) = "序号"
.textmatrix(0, 1) = "编号"
.textmatrix(0, 2) = "名称"
.textmatrix(0, 3) = "规格"
.textmatrix(0, 4) = "单位"
.textmatrix(0, 5) = "单价"
*****************************************************
关键之处|
———
.row = 0
for i = 0 to .cols – 1
.col = i
.cellalignment = flexaligncentercenter 居中对齐
next i
.row = 1
call loaddata 载入数据
*****************************************************
end with
end sub
以上显示为:
(图一)
错误写法一.
如果将“关键之处” 的
.row=0 去掉,即改写为:
*****************************************************
关键之处|
———
for i = 0 to .cols – 1
.col = i
.cellalignment = flexaligncentercenter 居中对齐
next i
.row = 1
call loaddata 载入数据
*****************************************************
或者将“关键之处”的
.row=0 和.row=1一起去掉,即改写为:
*****************************************************
关键之处|
———
for i = 0 to .cols – 1
.col = i
.cellalignment = flexaligncentercenter 居中对齐
next i
call loaddata 载入数据
*****************************************************
那么则显示为第二行居中,表头没有居中:
(图二)
错误写法二.
如果将“关键之处” 的
.row=1 去掉,即改写为:
*****************************************************
关键之处|
———
.row=0
for i = 0 to .cols – 1
.col = i
.cellalignment = flexaligncentercenter 居中对齐
next i
call loaddata 载入数据
*****************************************************
那么则显示为表头居中,但却把第一行第二行选中了:
(图三)
正确写法二.
如果将“关键之处” 的
改写为:
*****************************************************
关键之处|
———
call loaddata 载入数据
.row=0
for i = 0 to .cols – 1
.col = i
.cellalignment = flexaligncentercenter 居中对齐
next i
.row = 1
*****************************************************
只要保留.row=0,有没有.row=1都可正确显示
显示图和(图一)一样