-
Mar 30th, 2020, 11:29 PM
#1
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
-
Mar 31st, 2020, 07:27 AM
#2
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.
-
Jul 18th, 2021, 05:40 PM
#3
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
-
Jul 18th, 2021, 08:53 PM
#4
Re: VB6 HTMLGrid-UserControl
Originally Posted by shagratt
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.
-
Jul 24th, 2022, 07:54 AM
#5
Registered User
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
-
Jul 24th, 2022, 07:07 PM
#6
Re: VB6 HTMLGrid-UserControl
Originally Posted by ogcfrank
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
-
Jul 25th, 2022, 12:27 AM
#7
Registered User
Re: VB6 HTMLGrid-UserControl
Hi Olaf ,
Thank you very much .
Best Regards
Frank
-
Sep 15th, 2022, 08:59 AM
#8
New Member
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|