开发者

Adding a scroll bar to a label

开发者 https://www.devze.com 2023-02-25 19:36 出处:网络
I have a label on a userForm and the data within it is in list form.The data is longer than the label.Without expanding the label, is there a way to add a scro开发者_开发知识库ll bar to it?Or is there

I have a label on a userForm and the data within it is in list form. The data is longer than the label. Without expanding the label, is there a way to add a scro开发者_开发知识库ll bar to it? Or is there another option? Basically I want a box that does not have a scroll bar unless the list is longer than the box, then there's a scroll bar.

Using Excel vba userForm


You can used a textbox styled to look like a label. Set it to multiline with scrollbars set to vertical. Scrollbars will only show up if the content exceeds the size.


You can't have scroll bar for label, instead a textbox can be used. Set textbox with "Enabled" and "Locked" properties as"true". User will then have a scrollable and noneditable view

For vertical scrolling, set "WordWrap" and "MultiLine" to True

  • Now you could view the scroll bar on tapping the textbox. If you want the scroll bar to be visible by default, on the form load event we need to set the focus of textbox as below:

    Private Sub UserForm_Initialize() errorText.SetFocus End Sub

0

精彩评论

暂无评论...
验证码 换一张
取 消