|
-
Apr 25th, 2010, 10:19 PM
#1
Thread Starter
Lively Member
MshFlexgrid in vb 6.0
Hi,
I am not able to get entire rows as per my access database in MSHFlexgrid, can anyone please suggest
Access DB example:
WORD MEANING
Deprive Not allow to have: to prevent somebody from having somethingTake away: to take something away from somebody; Depose: to depose somebody from high rank office
Below is my code:
Code:
Set oRs = oConn.Execute(sql)
mfgViewData.Clear
mfgViewData.Rows = 2
mfgViewData.Cols = 2
mfgViewData.TextMatrix(0, 0) = "WORD"
mfgViewData.TextMatrix(0, 1) = "MEANING"
mfgViewData.ColWidth(0) = 1500
mfgViewData.ColWidth(1) = 4000
With oRs
Do While oRs.EOF = False
mfgViewData.AddItem ""
mfgViewData.TextMatrix(mfgViewData.Rows - 2, 0) = .Fields("WORD")
mfgViewData.TextMatrix(mfgViewData.Rows - 2, 1) = .Fields("MEANING")
.MoveNext
Loop
End With
Is there any oother way to view the data
db:access
application: vb 6.0
Thanks in advance
-
Apr 26th, 2010, 02:28 AM
#2
Re: MshFlexgrid in vb 6.0
Try adding the items like this.
Code:
Do While oRs.EOF = False
mfgViewData.AddItem .Fields("WORD") & vbTab & .Fields("MEANING")
.MoveNext
Loop
-
Apr 26th, 2010, 05:15 AM
#3
Thread Starter
Lively Member
Re: MshFlexgrid in vb 6.0
i tried ur code...but was not successfull..
actually can we get the data in MsFlexgrid in multple lines? as the data is coming in single line andmost of the data is gettng missed..
-
Apr 27th, 2010, 06:14 AM
#4
Re: MshFlexgrid in vb 6.0
Is all of the data in a single record in the database?
If so, then you would need to parse it into individual lines prior to adding it to your grid.
-
Apr 27th, 2010, 08:35 AM
#5
Re: MshFlexgrid in vb 6.0
If the problem is the text being too long for the cell then you could implement Wordwrapping, like this:
Code:
Dim lOriginalRowHeight As Long, lRowsNeeded As Long, lAux As String
Set oRs = oConn.Execute(Sql)
With mfgViewData
.Clear
.Rows = 2
.Cols = 2
.TextMatrix(0, 0) = "WORD"
.TextMatrix(0, 1) = "MEANING"
.ColWidth(0) = 1500
.ColWidth(1) = 4000
.WordWrap = True
lOriginalRowHeight = .RowHeight(mfgViewData.Rows - 1)
Do While Not oRs.EOF
mfgViewData.AddItem vbNullString
lAux = IIf(IsNull(oRs.Fields("MEANING")), vbNullString, oRs.Fields("MEANING"))
lRowsNeeded = Fix(Me.TextWidth(lAux) / .ColWidth(1)) + 1
.TextMatrix(mfgViewData.Rows - 2, 0) = oRs.Fields("WORD")
.TextMatrix(mfgViewData.Rows - 2, 1) = lAux
.RowHeight(mfgViewData.Rows - 2) = lOriginalRowHeight * lRowsNeeded
oRs.MoveNext
Loop
End With
The only problem you might have here is TextWidth(), it seems it's truncated when the string contains CR (Carriage return / jump to next line), does your column MEANING contains carriage returns?
EDIT: in order for TextWidth to work the Form's and the Flexgrid's Font should be the same (Same FontName, size, style..)
Last edited by jcis; Apr 27th, 2010 at 08:41 AM.
-
Apr 27th, 2010, 09:39 AM
#6
Thread Starter
Lively Member
Re: MshFlexgrid in vb 6.0
yeah it contains carriage returns..
-
Apr 27th, 2010, 09:50 AM
#7
Thread Starter
Lively Member
Re: MshFlexgrid in vb 6.0
Hey i tried with your code and did some changes..it is working now..
Thanks a lottttttttttttttttttttt for your help..
-
Apr 27th, 2010, 10:48 AM
#8
Re: MshFlexgrid in vb 6.0
About the problem with CR now i see it can be solved by using TextHeight here are the changes needed..
Code:
Dim lOriginalRowHeight As Long, lRowsForWidthNeeded As Long, lRowsForHeightNeeded As Long, lAux As String
Set oRs = oConn.Execute(Sql)
With mfgViewData
.Clear
.ScrollTrack = True
.Rows = 2: .Cols = 2
.TextMatrix(0, 0) = "WORD"
.TextMatrix(0, 1) = "MEANING"
.ColWidth(0) = 1500
.ColWidth(1) = 4000
.WordWrap = True
lOriginalRowHeight = .RowHeight(0) - 40
Do While Not oRs.EOF
mfgViewData.AddItem vbNullString
If Not IsNull(oRs.Fields("MEANING")) Then
lAux = oRs.Fields("MEANING")
lRowsForWidthNeeded = Fix(Me.TextWidth(lAux) / .ColWidth(1)) + 1
lRowsForHeightNeeded = Me.TextHeight(lAux) / Me.TextHeight(vbNullString)
.TextMatrix(mfgViewData.Rows - 2, 0) = oRs.Fields("WORD")
.TextMatrix(mfgViewData.Rows - 2, 1) = lAux
.RowHeight(mfgViewData.Rows - 2) = lOriginalRowHeight * lRowsForWidthNeeded * lRowsForHeightNeeded + 40
End If
oRs.MoveNext
Loop
End With
Last edited by jcis; Apr 27th, 2010 at 11:02 AM.
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
|