Microsoft Office Tutorials and References
In Depth Information
A Resizable UserForm
Figure 15-18 shows the UserForm that’s described in this section. It contains a ListBox control
that displays data from a worksheet. Notice the scrollbars on the ListBox. That means the ListBox
contains information that doesn’t fit. Also, notice the bottom-right corner of the dialog box. It
displays a (perhaps) familiar sizing control.
Figure 15-18: This is a resizable UserForm.
Figure 15-19 shows the same UserForm after the user resized it. Notice that the size of the ListBox
is also increased, and the Close button remains in the same relative position. You can stretch this
UserForm to the limits of your monitor.
This example is available on the companion CD-ROM. The filename is resizable
userform.xlsm .
The trick here involves a Label control, which is added to the UserForm at runtime. The sizing
control at the bottom-right corner is actually a Label control that displays a single character:
The letter o (character 111) from the Marlett font, character set 2. This control (named
objResizer ) is added to the UserForm in the UserForm_Initialize procedure:
Private Sub UserForm_Initialize()
‘ Add a resizing control to bottom right corner of UserForm
Set objResizer = Me.Controls.Add(“Forms.label.1”, MResizer, True)
With objResizer
.Caption = Chr(111)
.Font.Name = “Marlett”
.Font.Charset = 2
.Font.Size = 14
.BackStyle = fmBackStyleTransparent
.AutoSize = True
.ForeColor = RGB(100, 100, 100)
.MousePointer = fmMousePointerSizeNWSE
.ZOrder
 
Search JabSto ::




Custom Search