webbrowser中的html表(VB)

时间:2014-09-02 14:36:14

标签: html vb.net browser html-table

我正致力于从访问数据库创建表。它循环访问数据库查找任何匹配项,然后在Web浏览器中显示它们。

目前我有行显示,但我喜欢在onclick上显示下面的行。我不确定这种布局是否可行。关于不同方法的想法?

    Private Sub Populate_HtmlTable(ByRef dt As DataTable)


    Dim table As String = "<html>" & vbCrLf & _
        "<head>" & vbCrLf & _
        "</head>" & vbCrLf & _
        "<body > " & vbCrLf & _
        "<table>"


    Label5.Text = "RESULTS RETURNED : " + dt.Rows.Count.ToString
    If dt.Rows.Count = False Then
        table += "<tr><td> No Results Returned</td> </tr>"

    Else
        For i As Integer = 0 To dt.Rows.Count - 1
            table += "<tr>"

            Dim tCellDataItem As New HtmlTableCell()
            Dim tCellIntervention As New HtmlTableCell()
            Dim tCellTags As New HtmlTableCell()
            Dim tCellPR As New HtmlTableCell()
            Dim tCellGrade As New HtmlTableCell()
            Dim tCellRR As New HtmlTableCell()
            Dim tCellEvidence As New HtmlTableCell()
            Dim tCellBibliography As New HtmlTableCell()


            'Cell Intervention Title
            Dim data_item As String = ""
            If Not IsDBNull(dt.Rows(i)("data_item")) Then data_item = "<strong>" + dt.Rows(i)(1).ToString() + "</strong><br>"
            tCellDataItem.InnerHtml = data_item

            'Cell Intervention
            Dim intervention As String = ""
            If Not IsDBNull(dt.Rows(i)("intervention")) Then intervention = dt.Rows(i)(3).ToString()
            tCellIntervention.InnerHtml = intervention

            'Cell Tags
            Dim tags As String = ""
            If Not IsDBNull(dt.Rows(i)("Tags")) Then tags = dt.Rows(i)(10).ToString()
            tCellTags.InnerHtml = tags


            'Add Cells to Rows and then add Rows to table
            table += "<td valign=""top"">" + tCellDataItem.InnerHtml + "</td>"
            'table += "</tr>"

            '1st Drop Down'
            'Interventions


//IF THEY CLICK HERE
    table += "<tr><td style=""border:solid; border-bottom-width:2px;""> Intervention Description</td> </tr>"
//DISPLAY THESE ROWS             
            table += "<tr><td>" + tCellIntervention.InnerHtml + "</td></tr>"
            table += "<tr><td>&nbsp;</td></tr>"
            table += "<tr><td><strong>Tags: </strong>" + tCellTags.InnerHtml + "</td></tr>"
            table += "<tr><td>&nbsp;</td></tr>"
  //MORE Info cut out similar to above.
       Next
    End If
    table += "</table></body></html>"

    My.Computer.FileSystem.DeleteFile(Application.StartupPath + "\site.html")
    My.Computer.FileSystem.WriteAllText(Application.StartupPath + "\site.html", table, True)
    WebBrowser1.Navigate(Application.StartupPath + "\site.html")

0 个答案:

没有答案