Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

DataGrid wordwrap

Status
Not open for further replies.

RTDesi

MIS
Apr 17, 2001
24
US
Hey, I"m using a datagrid trying to display a table from an access database. Basically, I want to show all the records in the table. Some of the fields are quite lengthy (ie memo datatype). I tried using the 'wrap text' option found in the properties under the layout tab. For some reason, the whole record is still not displayed. Any info on this will be greatly appreciated. Thanks in advance
 
Basically, I made the cell a specified width and I wanted the text to wrap if it exceeded the width of the cell. So, 'making the cell big enough' wouldnt be a problem. That's what I"m trying to avoid. I dont want to have to size the cell the fit the text, but rather, have the amount of text dictate the size of the cell.
 
Using the FlexGrid I calculate the rowheight depending on the length of the text I want to display. First I set the minimum rowheight.

dim iLength as Integer
dim iCellWidth as integer
iCellWidth = 15 'specify the number of characters that can be displayed in a cell with standard height
With FG1
.RowHeightMin = TextHeight("X")
.WordWrap = True
iLength = Len(Trim(TextToDisplay))
if iLength > 15 then
'set the height of the last added row
.RowHeight(.Rows -1) = TextHeight("X") * iLength \15
end if
End With

It works in a flexgrid, so it might also work in a datagrid, but I haven't tested it.

Herman :-Q
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top