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
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..
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.
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..)
Re: MshFlexgrid in vb 6.0
yeah it contains carriage returns..
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..
:)
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