If word-wrapping isn't even possible in a GridView, then the above is a moot point and I'll go back to figuring out how to make simple things more complicated.
![Laughing :lol:](./images/smilies/icon_lol.gif)
For Each MGlobal.hResData
If Len(MGlobal.hResData!page_desc) > 45 Then ' set length for wrap
gridviewPages.Rows[iRow].Height = 50 ' set row height for wrapped text
sText = MGlobal.hResData!page_desc
WordWrap()
Else
sWordWrap = MGlobal.hResData!page_desc
Endif
gridviewPages[iRow, 0].Text = MGlobal.hResData!id
gridviewPages[iRow, 1].Text = Str$(DateAdd(CDate("1/1/1970"), gb.Second, Global.hResData!page_rec_date)) ' convert from unix timestamp
gridviewPages[iRow, 2].Text = MGlobal.hResData!page_name
gridviewPages[iRow, 3].Text = MGlobal.hResData!sql_table_name
gridviewPages[iRow, 4].Text = sWordWrap
sWordWrap = ""
Inc iRow
Next
This routine does the wrapping. It finds the best spot to wrap so no words are split.
Public Sub WordWrap()
Dim siPos As Short = 45 ' wrap length
While Mid$(sText, siPos, 1) <> " " ' find white space to make clean wrap
Dec siPos
Wend
sWordWrap = Mid$(sText, 1, siPos) & Chr(10) & Mid$(sText, siPos + 1) ' wrap
End
What the results look like....
Public Function WordWrap(TextToWrap As String, LengthToWrap As Integer) As String
Dim iCount As Integer
iCount = LengthToWrap
While Mid$(TextToWrap, iCount, 1) <> " " 'find first white space backward from LenghtToWrap to make the split
Dec iCount
Wend
Return Subst("&1\n&2", Mid$(TextToWrap, 1, iCount), Mid$(TextToWrap, iCount + 1))
End
Usage in you example would be:
For Each MGlobal.hResData
If Len(MGlobal.hResData!page_desc) > 45 Then ' set length for wrap
gridviewPages.Rows[iRow].Height = 50 ' set row height for wrapped text
sText = MGlobal.hResData!page_desc
sWordWrap = WordWrap(sText, 45)
Else
sWordWrap = MGlobal.hResData!page_desc
Endif
gridviewPages[iRow, 0].Text = MGlobal.hResData!id
gridviewPages[iRow, 1].Text = Str$(DateAdd(CDate("1/1/1970"), gb.Second, Global.hResData!page_rec_date)) ' convert from unix timestamp
gridviewPages[iRow, 2].Text = MGlobal.hResData!page_name
gridviewPages[iRow, 3].Text = MGlobal.hResData!sql_table_name
gridviewPages[iRow, 4].Text = sWordWrap
sWordWrap = ""
Inc iRow
Next
Want to split in 3 lines say at 45 and 90?
sWordWrap = WordWrap(WordWrap(sText, 90), 45)
And you can go on and on and on....Nice! Glad my code was found useful and made even better with only slight modifications.
Print gridviewPages.Rows[iRow].Height
would tell me a row's height, but it escaped me at the time I posted the question above. It actually doesn't matter because it really wasn't what I was after.gridviewPages.Rows[iRow].Height = Desktop.Scale * 2 * 2 + 8
would set a GridView's row height when word wrapping.