Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 278
  • Last Modified:

ASP.net VB.net Dynamically build a table

Hi

What VB.net code would I use to dynamically add a table to a panel
Then add a certain number of rows and columns to that table
0
Murray Brown
Asked:
Murray Brown
1 Solution
 
Pratima PharandeCommented:
try this

Dim rowCnt As Integer
        ' Current row count
        Dim rowCtr As Integer
        ' Total number of cells (columns).
        Dim cellCtr As Integer
        ' Current cell counter.
        Dim cellCnt As Integer
        Dim Table1 As New Table
        rowCnt = 2
        cellCnt = 3
        Table1.BorderWidth = 1
        Table1.BorderColor = Drawing.Color.Black
        Table1.BorderStyle = BorderStyle.Solid
        Table1.GridLines = GridLines.Both

        For rowCtr = 1 To rowCnt
            Dim tRow As New TableRow()
            For cellCtr = 1 To cellCnt
                Dim tCell As New TableCell()
                tCell.Text = "Row " & rowCtr & ", Cell " & cellCtr
                ' Add new TableCell object to row.
                tRow.Cells.Add(tCell)
            Next
            ' Add new row to table.
            Table1.Rows.Add(tRow)
            Panel1.Controls.Add(Table1)
0
 
Murray BrownMicrosoft Cloud Azure/Excel Solution DeveloperAuthor Commented:
Thanks very much
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now