我基本上以编程方式生成许多标签,其中包含从文本文件中读取的文本,因此我想知道如何以编程方式将Label的宽度调整为其文本。
答案 0 :(得分:3)
控件有两种风格。标签的ActiveX版本具有AutoSize
属性。例如,在Label1
Sheet1
的ActiveX标签控件
Private Sub test()
Sheet1.Label1.WordWrap = False
Sheet1.Label1.AutoSize = True
Sheet1.Label1.Caption = "This is a lot of text to put in a label"
End Sub
会自动调整宽度以适应。