Results 1 to 8 of 8

Thread: VB6 HTMLGrid-UserControl

  1. #1

    Thread Starter
    PowerPoster
    Join Date
    Jun 2013
    Posts
    7,219

    VB6 HTMLGrid-UserControl

    A (Property-wise) quite simple to manage Grid-Control (with not much Code in it, only about 150 lines),
    which makes use of the nicer Formatting-Options of HTML-rendering...

    It uses an internal (dynamically loaded - and LateBound) MS-WebBrowser-control, to visualize the Grid.
    Also included in the project is the cIEFeatures.cls, which will "lift-up" the IE-BrowserControl to more modern versions.
    (Note, that it will probably not render properly on XP - maybe it does - but I'm not testing stuff on that OS anymore)

    I've made this example, since recent questions were asking for "InCell-Formatting-options" -
    and this Demo shows, how such an HTML-based Grid can handle this requirement.

    The "Filling" of that Grid is based on an "HTML-string", which one has to concatenate himself
    (using the relative short <tr>, <th> and <td> tags).

    The Demo generates this String from a normally selected ADO-Rs in a Loop
    (using String-Arrays for the build-up, which later get Joined when they are passed as the Grids InputString).

    Here is a ScreenShot:



    And here the little Demo:
    HTMLGrid.zip

    Have fun,

    Olaf

  2. #2
    PowerPoster
    Join Date
    Sep 2012
    Posts
    2,083

    Re: VB6 HTMLGrid-UserControl

    Hi Olaf, I tested your HTMLGrid and it worked very well on win10.

    On XP, the following message is displayed:
    Code:
    An error has occurred in a script on this page.
    Object doesn't support this property or method
    HTML + JavaScript is an excellent UI design combination, but JavaScript debugging is very inconvenient. I don't even know how to debug JavaScript in IE6.

    There is a crazy idea that keeps circling in my mind: Is it possible to use RC5.Cairo to simulate HTML.DOM or even WebBrowser? (I'll ask this question in another thread)
    Last edited by dreammanor; Mar 31st, 2020 at 07:32 AM.

  3. #3
    Addicted Member shagratt's Avatar
    Join Date
    Jul 2019
    Location
    Argentina
    Posts
    198

    Re: VB6 HTMLGrid-UserControl

    Really good work Olaf! thanks for sharing it.
    It also looks good to study it and use to create the base for other type of web based controls

  4. #4
    Frenzied Member
    Join Date
    Aug 2020
    Posts
    1,421

    Re: VB6 HTMLGrid-UserControl

    Quote Originally Posted by shagratt View Post
    Really good work Olaf! thanks for sharing it.
    It also looks good to study it and use to create the base for other type of web based controls
    You are an expert in user control, and perhaps you could use OP's example as a seed to cultivate a beautiful garden. Web-based controls will greatly extend the scope of VB6 applications.

  5. #5
    Registered User
    Join Date
    Jan 2019
    Posts
    2

    Re: VB6 HTMLGrid-UserControl

    Hi Olaf ,

    I tested your HTMLGrid , this demo has only two columns ,so if I want to get more colimns , how to do ?



    Thank you
    Best Regards
    Frank

  6. #6

    Thread Starter
    PowerPoster
    Join Date
    Jun 2013
    Posts
    7,219

    Re: VB6 HTMLGrid-UserControl

    Quote Originally Posted by ogcfrank View Post
    I tested your HTMLGrid , this demo has only two columns ,so if I want to get more colimns , how to do ?
    Ok, the Rs-based FillRoutine was somewhat specific for that Bible-example...

    But it doesn't cost much effort, to make it a bit more generic (working with all Rs) -
    just change 2 routines (in fTest) to:
    Code:
    Private Sub cmdFillGrid_Click()
      Dim T!: T = Timer 'stop the timing for the whole fill-operation (including the Select from the DB)
        'retrieve the Input-Rs
        Set RsVerses = Cnn.Execute("Select ID As [Book:Chp:Vrs], Scripture, 123 as Num, 'ABC' as Txt From Verses")
        'define the Css-Values (width- and alignment-values) for certain Columns
        Dim ColDefs()
        ColDefs = Array("min-width:90px; text-align:right;", _
                        "min-width:120px; width:900px; text-align:left;", _
                        "width:auto; text-align:right;", _
                        "width:auto; text-align:left;")
        'and call the now somewhat more generic Rs-based FillRoutine
        FillGridFromRs RsVerses, ColDefs
      Caption = "HTML-GridControl (selected and filled " & RsVerses.RecordCount & " records, in " & Format((Timer - T) * 1000, "0msec") & ")"
    End Sub
    
    Private Sub FillGridFromRs(Rs As ADODB.Recordset, ColDefs())
      Dim i As Long, j As Long, trHeader As String
      For j = 0 To Rs.Fields.Count - 1
          trHeader = trHeader & "<th>" & Rs.Fields(j).Name & "</th>" 'enclose each Hdr-Field with th-tags
      Next
      trHeader = "<tr>" & trHeader & "</tr>" 'finally add the yet missing tr-Tags around the Header-string
      
      ReDim Cols(0 To Rs.Fields.Count - 1) As String
      ReDim trRows(1 To Rs.RecordCount) As String
     
      For i = 1 To Rs.RecordCount
          Rs.AbsolutePosition = i
    
          For j = 0 To Rs.Fields.Count - 1
              Cols(j) = "" & Rs.Fields(j).Value
          Next
     
          trRows(i) = "<tr><td>" & Join(Cols, "</td><td>") & "</td></tr>" 'each rows col-content is joined with td-tags and wrapped in "outer tr-tags"
      Next
      
      'finally we refresh the Grid with the just build-up String-contents (+ Column-formatting-infos in the last ParamArray)
      ucHtmlGrid1.Refresh trHeader, trRows, ColDefs
    
      ucHtmlGrid1.SetZoomPercent 100 '<- yes, InGrid-Zooming "comes for free" with HTML-rendering
    End Sub
    Plus a small change on the ucHtmlGrid...
    Remove the ParamArray-Keyword from the last Param of the Refresh-Routine,
    so that it becomes:
    Code:
    Public Sub Refresh(trHeader As String, trRows() As String, ColDefs())
    ...
    But that's it...

    HTH

    Olaf

  7. #7
    Registered User
    Join Date
    Jan 2019
    Posts
    2

    Re: VB6 HTMLGrid-UserControl

    Hi Olaf ,

    Thank you very much .

    Best Regards
    Frank

  8. #8
    New Member
    Join Date
    Sep 2021
    Posts
    8

    Re: VB6 HTMLGrid-UserControl

    Hi Olaf ,
    Thank you so much for sharing your valuable knowledge.
    please help me how to display column name in access on header of HTMLGrid

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width