首页 > 开发 > 综合 > 正文

DataGrid合併行

2024-07-21 02:22:56
字体:
来源:转载
供稿:网友
private sub unitdatagriditem(byval intcell as integer)
dim objdatagriditem as datagriditem
dim strcell1 as string = ""
dim strcell2 as string = ""
dim objliteralcontrol as literalcontrol
dim intspan as integer = 1
dim objdatagriditemtospan as datagriditem
dim i, j as integer
dim strtemp as string
for i = 0 to datagrid1.items.count - 1
intspan = 1
objliteralcontrol = ctype(datagrid1.items(i).cells(intcell).controls(0), literalcontrol)
strcell1 = objliteralcontrol.text

for j = i + 1 to datagrid1.items.count - 1
objliteralcontrol = ctype(datagrid1.items(j).cells(intcell).controls(0), literalcontrol)
strcell2 = objliteralcontrol.text
if strcell1 = strcell2 then
intspan += 1
datagrid1.items(i).cells(intcell).rowspan = intspan
datagrid1.items(j).cells(intcell).visible = false
else
exit for
end if
next
i = j - 1
next

end sub
除了設定rowspan 外,還要把下面行的visible 設成false,否則不起作用,底下會多出一個column.這個datagrid的每個cell中都包含一個literalcontrol,如果沒有的話,就直接用datagrid1.items(i).cells(intcell).text即可.參數intcell ,是指要合併的那個列.


最大的网站源码资源下载站,

发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表