PRB: Label Grows Wider When AutoSize and WordWrap Are TrueLast reviewed: November 19, 1996Article ID: Q135651 |
The information in this article applies to:
SYMPTOMSAs more text is added to a Label Control that has the AutoSize and WordWrap properties set to True, both the width and the height of the label increase. This is not what you might expect, which is that only the height of the label would increase.
WORKAROUNDSet the Width property back to the original width explicitly after adding text to the caption of the label.
STATUSMicrosoft is researching this behavior and will post new information here in the Microsoft Knowledge Base as it becomes available. This behavior has been modified in Visual Basic version 4.0. Increases in the width of the Label control after text is added to the caption are now significantly smaller than the increases seen in version 3.0, although they do still occur. Also, in version 4.0, the width of the label doesn't become larger and larger when you repeatedly add text to the caption. In Version 3.0, the width of the label continues increasing as more text is repeatedly added to the caption.
MORE INFORMATION
Steps to Reproduce Behavior
Example WorkaroundTo prevent the width from becoming excessively large, you can use this code:
MsgBox "Start Width=" & Label1.Width OriginalWidth = Label1.Width Label1.Visible = False For i = 1 To 50 Label1.Caption = Label1.Caption & "This is my Text " Next Label1.Width = OriginalWidth Label1.Visible = True MsgBox "Final Width=" & Label1.WidthThis workaround suitable only for solving the large increases in label width that are seen in version 3.0. The AutoSize feature will probably cause the final width of the control to be slightly larger than the original width of the label as more text is added, even when the width is explicitly set. The differences between the initial and final widths of the control after text is added to the caption will depend on the content of the new caption and the font characteristics. By setting the AutoSize property of the label to False before setting the label width back, the original width can be obtained. However, this will result in text being truncated.
|
Additional reference words: 4.00 3.00 Windows 95 vb4all
© 1998 Microsoft Corporation. All rights reserved. Terms of Use. |