Height、Width、Left、Top、ClientHeight、ClientWidth、ClientLeft、ClientTop 属性、TabStrip、Image 控件示例
以下示例在用户单击 CommandButton 时,将 Image 的尺寸设置为 TabStrip 工作区的大小。
此代码示例使用以下属性: Height 和 Width、 Left 和 Top 以及 ClientHeight、ClientLeft、ClientTop 和 ClientWidth。
若要使用此示例,请将此示例代码复制到窗体的 Declarations 部分。 确保该窗体包含:
- 名为 CommandButton1 的 CommandButton。
- 名为 TabStrip1 的 TabStrip。
- 名为 Image1 的 Image。
Private Sub UserForm_Initialize()
CommandButton1.Caption = "Size Image to Tab Area"
CommandButton1.WordWrap = True
CommandButton1.AutoSize = True
End Sub
Private Sub CommandButton1_Click()
Image1.ZOrder(fmFront)
'Place Image in front of TabStrip
'ClientLeft and ClientTop are measured from the edge
'of the TabStrip, not from the edges of the form
'containing the TabStrip.
Image1.Left = TabStrip1.Left + TabStrip1.ClientLeft
Image1.Top = TabStrip1.Top + TabStrip1.ClientTop
Image1.Width = TabStrip1.ClientWidth
Image1.Height = TabStrip1.ClientHeight
End Sub
支持和反馈
有关于 Office VBA 或本文档的疑问或反馈? 请参阅 Office VBA 支持和反馈,获取有关如何接收支持和提供反馈的指南。