WordWrap
This is a property of the label control, which should allow it to dynamically resize vertically. Handled carefully, it will do that. Beginning in VFP 7, it's also a property of grid headers, allowing their captions to contain multiple lines of text. Given that we've been asking for this since VFP 3, it's about time.
Usage |
oObject.WordWrap = lWordWrap lWordWrap = oObject.WordWrap |
Setting WordWrap True doesn't automatically wrap your text to a previously set width. You need to either manually set the height of the label, or turn on AutoSize after setting WordWrap .T. before the text will wrap. We expected that WordWrap would cause Height to automatically resize to fit the text, but Microsoft's solution to this makes sense, too. |
="First part of caption" + CHR(13) + "Second part of caption"Actually, it wouldn't look a whole lot different in code. Watch out—if you add CHR(13) to a header's Caption and fail to set WordWrap to .T., you might see a garbage character where you meant to put a line break.
Example |
* Try these from the Command Window. x=CreateObject("form") x.Visible = .t. x.AddObject("MyLabel","Label") x.mylabel.Visible = .t. x.mylabel.Caption = "Now I can wrap enough words to occupy " ; + "four lines of text" * Only as much text as can fit in the default size appears. x.mylabel.WordWrap = .t. && Still no more text. x.mylabel.Height = 4*x.mylabel.Height && Now it appears! * An example for the grid header: USE _Samples + "\data\orders.dbf" x=CreateObject("form") x.Visible = .t. x.AddObject("grdGrid","grid") x.grdGrid.Visible=.t. x.grdgrid.column2.header1.Caption = "Multi-line "+CHR(13)+"Demo" x.grdgrid.column2.header1.WordWrap=.t. x.grdgrid.HeaderHeight=2*x.grdGrid.HeaderHeight |
See Also |
AutoSize, Caption, Header, HeaderHeight, Height, Label Control, Width |