WordWrap 属性示例 本例将文本放入两个 Label 控件并使用 WordWrap 属性来说明它们不同的行为。要试用此例,将下面的代码粘贴到包含两个 Label 控件的窗体的声明部分,然后按 F5 键 并单击窗体来转换 WordWrap 属性的设置值。Private Sub Form_Load () Dim Author1, Author2, Quote1, Quote2 ' 声明变量。 Label1.AutoSize = True ' 设置“自动调整大小”。 Label2.AutoSize = True Label1.WordWrap = True ' 设置“自动换行”。 Quote1 = "I couldn't wait for success, so I went on without it." Author1 = " - Jonathan Winters" Quote2 = "Logic is a system whereby one may go wrong with confidence." Author2 = " - Charles Kettering" Label1.Caption = Quote1 & Chr(10) & Author1 Label2.Caption = Quote2 & Chr(10) & Author2 End SubPrivate Sub Form_Click () Label1.Width = 1440 ' 将宽度设置为一英寸,以缇来表示。 Label2.Width = 1440 Label1.WordWrap = Not Label1.WordWrap ' 转换“自动换行”属性。 Label2.WordWrap = Not Label2.WordWrap End Sub
label1.wordwrap = true
label1.caption = "asdfasdfadsf" & chr(10) & "asdfasdf"
分....
首先把autosize属性设置为true 否则label1的长度不会随字符的增多而变长
然后把wordwrap属性设置为true 返回或设置一个值,该值用来指示一个 AutoSize 属性设置为 True 的 Label 控件,是否要进行水平或垂直展开以适合其 Caption 属性中指定的文本的要求。
chr(10)是换行符
分...
返回或设置一个值,该值用来指示一个 AutoSize 属性设置为 True 的 Label 控件,是否要进行水平或垂直展开以适合其 Caption 属性中指定的文本的要求。
本例将文本放入两个 Label 控件并使用 WordWrap 属性来说明它们不同的行为。要试用此例,将下面的代码粘贴到包含两个 Label 控件的窗体的声明部分,然后按 F5 键 并单击窗体来转换 WordWrap 属性的设置值。Private Sub Form_Load ()
Dim Author1, Author2, Quote1, Quote2 ' 声明变量。
Label1.AutoSize = True ' 设置“自动调整大小”。
Label2.AutoSize = True
Label1.WordWrap = True ' 设置“自动换行”。
Quote1 = "I couldn't wait for success, so I went on without it."
Author1 = " - Jonathan Winters"
Quote2 = "Logic is a system whereby one may go wrong with confidence."
Author2 = " - Charles Kettering"
Label1.Caption = Quote1 & Chr(10) & Author1
Label2.Caption = Quote2 & Chr(10) & Author2
End SubPrivate Sub Form_Click ()
Label1.Width = 1440 ' 将宽度设置为一英寸,以缇来表示。
Label2.Width = 1440
Label1.WordWrap = Not Label1.WordWrap ' 转换“自动换行”属性。
Label2.WordWrap = Not Label2.WordWrap
End Sub