[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

Need help freezing the header row and left most column in my html table.

Posted on 2014-01-13
1
Medium Priority
?
1,260 Views
Last Modified: 2014-01-15
I have read and tried to use some of the solutions for my problem that I have seen in other post, but have yet to get it to work properly.  The code below is my attempt to freeze the header row (I have yet to try the left most column).

     I know basically no html and have been trying to cut, paste and figure this out as I go.  Can someone please show me where I got it wrong?
    Private Sub btnSaveOutputFile_Click(sender As Object, e As EventArgs) Handles btnSaveOutputFile.Click
        'Saves known good and actual values to output.txt
        Dim objWriter As System.IO.StreamWriter
        Dim FirstTerm As String = String.Empty
        Dim SecondTerm As String = String.Empty
        Dim GSum As String = String.Empty
        Dim ASum As String = String.Empty
        Dim GProduct As String = String.Empty
        Dim GQuotient As String = String.Empty
        Dim AProduct As String = String.Empty
        Dim LineNum As String = String.Empty
        Dim AQuotient As String = String.Empty
        Dim sHTML As String

        'delete old file.
        File.Delete("output.html")
        'create new file.
        objWriter = System.IO.File.AppendText("output.html")

        sHTML = "<style style=""text/css"">"
        sHTML &= "  	.hoverTable{font-size:10pt;}"
        sHTML &= "  	.hoverTable{width:100%;border-collapse:collapse;}"
        sHTML &= "	.hoverTable td{padding:7px; border:#4e95f4 1px solid;}"
        sHTML &= "	/*  Define the background color for all the ODD background rows  */"
        sHTML &= "	.hoverTable tr:nth-child(odd){background: #b8d1f3;}"
        sHTML &= "	/*  Define the background color for all the EVEN background rows  */"
        sHTML &= "	.hoverTable tr:nth-child(even){background: #dae5f4;}"
        sHTML &= "	/* Define the hover highlight color for the table row */"
        sHTML &= "    .hoverTable tr:hover {background-color: #ffff99;}"
        sHTML &= "</style>"
        sHTML &= "<table class=""hoverTable"">"
        sHTML &= "<tr><th style=""vertical-align:top;text-align:left;height:20px;"">"
        sHTML &= "<div style=""position: fixed;top: expression(this.offsetParent.scrollTop);>"

        For Each col As DataGridViewColumn In DataGridView1.Columns
            sHTML &= "<td>" & col.HeaderText & "</td>"
        Next

        sHTML &= "</div></th></tr>"

        For Each row As DataGridViewRow In DataGridView1.Rows
            LineNum = row.Cells(0).Value
            FirstTerm = row.Cells(1).Value
            SecondTerm = row.Cells(2).Value
            GSum = row.Cells(3).Value
            ASum = row.Cells(4).Value
            GProduct = row.Cells(5).Value
            AProduct = row.Cells(6).Value
            GQuotient = row.Cells(7).Value
            AQuotient = row.Cells(8).Value

            sHTML &= "<tr><td style=""overflow: auto;"">" & LineNum & "</td><td style=""overflow: auto;"">" & FirstTerm & "</td><td style=""overflow: auto;"">" & SecondTerm & "</td><td style=""overflow: auto;"">" & GSum & _
                "</td><td style=""overflow: auto;"">" & ASum & "</td><td style=""overflow: auto;"">" & GProduct & "</td><td style=""overflow: auto;"">" & AProduct & "</td><td style=""overflow: auto;"">" & GQuotient & _
                "</td><td style=""overflow: auto;"">" & AQuotient & "</td></tr>"
        Next

        objWriter.WriteLine(sHTML)

        Me.Text = "HTML conversion completed"

        'close file.
        objWriter.Flush()
        objWriter.Close()

        System.Diagnostics.Process.Start("output.html")

    End Sub

Open in new window

0
Comment
Question by:NevSoFly
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 28

Accepted Solution

by:
Ark earned 2000 total points
ID: 39781259
To freeze header row with css is not so difficult. But to freeze first column you need some javascript/jquery. See http://fixed-header-using-jquery.blogspot.ru/2009/05/scrollable-table-with-fixed-header-and.html (see demo http://acatalept.com/common/test/fixed-table.html)
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!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Is your Office 365 signature not working the way you want it to? Are signature updates taking up too much of your time? Let's run through the most common problems that an IT administrator can encounter when dealing with Office 365 email signatures.
Q&A with Course Creator, Mark Lassoff, on the importance of HTML5 in the career of a modern-day developer.
In this tutorial viewers will learn how to style elements, such a divs, with a "drop shadow" effect using the CSS box-shadow property Start with a normal styled element, such as a div.: In the element's style, type the box shadow property: "box-shad…
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

656 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question