段名
dim str2 as string=myTable.columns(i).columnname
j=len(str2)
if j>0 then
myBool=true
for k=1 to j '判断字段名中是否包括汉字
dim str1 as char=mid(str2,k,1)
if ascw(str1)>255 then '有非ASCII字符
myBool=false
exit for
end if
next
if myBool then j=(j/2+0.5) 'ASCII字符,字符串长度减半
if j>aa(i) then aa(i)=j
end if
next
SetCellSize=aa
end Function
------------------------------------------------------
主要程序:
子程序ShowTables设置一些初始值,然后调用子程序ShowChildRows。
子程序ShowChildRows的参数说明:
Rows:是一个DataRow数组,第一次调用ShowChildRows时,是DataTable的所有的记录行。以后递归调用ShowChildRows时,是与父表某一记录行相关的子表的一些记录行。
myTable:Rows所属的DataTable,程序将使用它的Columns,即字段名行。
aa:函数子程序SetCellSize返回的一维整型数组。
spaces:整型参数,用于在网页显示Tables时,这些Tables左侧应设置几个空单元格,以显示Table的隶属关系。
signal:字符串参数,ImageButton的id值,用于生成相关的Tables和ImageButtons的id。
因为要在网页中添加Table控件,所以在网页中应有一个id为form1的Form控件。
动态地创建一个Table有三个步骤,首先,创建 TableCell 对象,即行中的单元格,添加单元格的内容有两种方法:设置 Text 属性,或者向 TableCell 的 Control.Controls 集合添加控件,程序中对某些单元格添加ImageButton控件;接下来,创建 TableRow 以表示表中的行,将此前创建的 TableCell 对象添加到 TableRow 的 Cells 集合中。最后,将 TableRow 添加到 Table 控件的 Rows 集合中。
以下是程序:
Sub S
dim str2 as string=myTable.columns(i).columnname
j=len(str2)
if j>0 then
myBool=true
for k=1 to j '判断字段名中是否包括汉字
dim str1 as char=mid(str2,k,1)
if ascw(str1)>255 then '有非ASCII字符
myBool=false
exit for
end if
next
if myBool then j=(j/2+0.5) 'ASCII字符,字符串长度减半
if j>aa(i) then aa(i)=j
end if
next
SetCellSize=aa
end Function
------------------------------------------------------
主要程序:
子程序ShowTables设置一些初始值,然后调用子程序ShowChildRows。
子程序ShowChildRows的参数说明:
Rows:是一个DataRow数组,第一次调用ShowChildRows时,是DataTable的所有的记录行。以后递归调用ShowChildRows时,是与父表某一记录行相关的子表的一些记录行。
myTable:Rows所属的DataTable,程序将使用它的Columns,即字段名行。
aa:函数子程序SetCellSize返回的一维整型数组。
spaces:整型参数,用于在网页显示Tables时,这些Tables左侧应设置几个空单元格,以显示Table的隶属关系。
signal:字符串参数,ImageButton的id值,用于生成相关的Tables和ImageButtons的id。
因为要在网页中添加Table控件,所以在网页中应有一个id为form1的Form控件。
动态地创建一个Table有三个步骤,首先,创建 TableCell 对象,即行中的单元格,添加单元格的内容有两种方法:设置 Text 属性,或者向 TableCell 的 Control.Controls 集合添加控件,程序中对某些单元格添加ImageButton控件;接下来,创建 TableRow 以表示表中的行,将此前创建的 TableCell 对象添加到 TableRow 的 Cells 集合中。最后,将 TableRow 添加到 Table 控件的 Rows 集合中。
以下是程序:
Sub S
| 对此文章发表了评论 |

