使用VB.net创建动态表

时间:2012-10-05 18:27:38

标签: vb.net

我的代码中存在这个小问题只是创建/显示最后一个tablecell。我知道这可能是一些小事,但无法弄清楚我做错了什么。这是我的代码如下。

    Dim tbl As Table = New Table()

    tblrow = New TableRow
    tblcell = New TableHeaderCell
    tblcell.Text = zone_name
    tblcell.HorizontalAlign = HorizontalAlign.Center
    tblrow.Cells.Add(tblcell)
    tbl.Rows.Add(tblrow)

    tblrow = New TableRow
    tblcell = New TableCell
    lblDesc = New Label
    lblDesc.ID = "lbl_" & zone_name
    lblDesc.Text = randomNum
    tblcell.HorizontalAlign = HorizontalAlign.Center
    tblcell.Controls.Add(lblDesc)
    tblrow.Cells.Add(tblcell)

    tbl.Rows.Add(tblrow)

** * ** * * 修改< / EM> * ** * ** * ** * ***

公共函数add_table(ByVal zone_name As String,ByVal hgt As Integer,ByVal randomNum As Integer,ByVal fontSize As Integer)

    Dim tbl As Table = New Table()

    tbl.ID = "tbl_" & zone_name

    tblrow = New TableRow
    tblcell = New TableCell

    tblcell.Text = zone_name
    tblcell.HorizontalAlign = HorizontalAlign.Center
    tblrow.Cells.Add(tblcell)

    tbl.Rows.Add(tblrow)

    tblrow = New TableRow
    tblcell = New TableCell

    lblDesc = New Label
    lblDesc.ID = "lbl_" & zone_name
    lblDesc.Text = randomNum
    tblcell.HorizontalAlign = HorizontalAlign.Center
    tblcell.Controls.Add(lblDesc)
    tblrow.Cells.Add(tblcell)

    tbl.Rows.Add(tblrow)

    Return tbl
End Function


    tblrow = New TableHeaderRow

    tblcell = New TableHeaderCell
    tblcell.Controls.Add(add_table(zone_name, hgt, randomNum, fontSize))
    tblSeatMap.Rows.Add(tblrow)

0 个答案:

没有答案