Table of contents
TOC
折叠目录
展开目录

CustomControl.SizeToFit 方法 (访问)CustomControl.SizeToFit Method (Access)

office 365 dev account|上次更新日期: 2018/3/13
|
2 参与人员

可以使用SizeToFit方法来调整控件的大小,使其适应文本或它所包含的图像。You can use the SizeToFit method to size a control so it fits the text or image that it contains.

语法Syntax

表达式SizeToFitexpression. SizeToFit

表达式_一个表示CustomControl对象的变量。_expression A variable that represents a CustomControl object.

注解Remarks

例如,可以将SizeToFit方法应用规模太小,在其标题属性中显示的所有文本的命令按钮。For example, you can apply the SizeToFit method to a command button that is too small to display all the text in its Caption property.

您可以应用SizeToFit方法对仅在窗体设计视图中的控件或报表设计视图。You can apply the SizeToFit method to controls only in form Design view or report Design view.

SizeToFit方法将使控件变大或变小,这取决于文本或它所包含的图像的大小。The SizeToFit method will make a control larger or smaller, depending on the size of the text or image it contains.

与新控件的大小,您必须在代码中创建的CreateControl方法,可以结合使用SizeToFit方法。You can use the SizeToFit method in conjunction with the CreateControl method to size new controls that you have created in code.

请注意 通过SizeToFit方法就可以调整大小并不是所有的控件包含文本或图像。多个控件绑定到数据可以变化的大小从一条记录到下一步。这些控件包括文本框、 列表框、 组合框和绑定的对象框控件。SizeToFit方法不适用于控件在数据访问页。Note Not all controls that contain text or an image can be sized by the SizeToFit method. Several controls are bound to data that can vary in size from one record to the next. These controls include the text box, list box, combo box, and bound object frame controls. The SizeToFit method does not apply to controls on data access pages.

示例Example

下面的示例创建一个新窗体和窗体上创建新的命令按钮。该过程然后设置控件的标题属性和控件的大小以容纳标题。The following example creates a new form and creates a new command button on the form. The procedure then sets the control's Caption property and sizes the control to fit the caption.

Sub SizeNewControl() 
 Dim frm As Form, ctl As Control 

 ' Create new form. 
 Set frm = CreateForm 
 ' Create new command button. 
 Set ctl = CreateControl(frm.Name, _ 
 acCommandButton, , , , 500, 500) 
 ' Restore form. 
 DoCmd.Restore 
 ' Set control's Caption property. 
 ctl.Caption = "Extremely Long Control Caption" 
 ' Size control to fit caption. 
 ctl.SizeToFit 
End Sub

另请参阅See also

概念Concepts

CustomControl 对象CustomControl Object

© 2018 Microsoft