Control Control Control Control Constructors

定义

重载

Control() Control() Control()

使用默认设置初始化 Control 类的新实例。Initializes a new instance of the Control class with default settings.

Control(String) Control(String) Control(String) Control(String)

用特定的文本初始化 Control 类的新实例。Initializes a new instance of the Control class with specific text.

Control(Control, String) Control(Control, String) Control(Control, String) Control(Control, String)

用特定文本将 Control 类的新实例初始化为子控件。Initializes a new instance of the Control class as a child control, with specific text.

Control(String, Int32, Int32, Int32, Int32) Control(String, Int32, Int32, Int32, Int32) Control(String, Int32, Int32, Int32, Int32) Control(String, Int32, Int32, Int32, Int32)

用特定的文本、大小和位置初始化 Control 类的新实例。Initializes a new instance of the Control class with specific text, size, and location.

Control(Control, String, Int32, Int32, Int32, Int32) Control(Control, String, Int32, Int32, Int32, Int32) Control(Control, String, Int32, Int32, Int32, Int32) Control(Control, String, Int32, Int32, Int32, Int32)

用特定的文本、大小和位置将 Control 类的新实例初始化为子控件。Initializes a new instance of the Control class as a child control, with specific text, size, and location.

Control() Control() Control()

使用默认设置初始化 Control 类的新实例。Initializes a new instance of the Control class with default settings.

public:
 Control();
public Control ();
Public Sub New ()

注解

Control类是在 Windows 窗体应用程序中使用的所有控件的基类。The Control class is the base class for all controls used in a Windows Forms application. 因为该类通常不用于创建类的实例,此构造函数通常不直接调用,但而通过派生类调用。Because this class is not typically used to create an instance of the class, this constructor is typically not called directly but is instead called by a derived class.

Control(String) Control(String) Control(String) Control(String)

用特定的文本初始化 Control 类的新实例。Initializes a new instance of the Control class with specific text.

public:
 Control(System::String ^ text);
public Control (string text);
new System.Windows.Forms.Control : string -> System.Windows.Forms.Control
Public Sub New (text As String)

参数

text
String String String String

控件显示的文本。The text displayed by the control.

注解

Control类是在 Windows 窗体应用程序中使用的所有控件的基类。The Control class is the base class for all controls used in a Windows Forms application. 因为该类通常不用于创建类的实例,此构造函数通常不直接调用,但而通过派生类调用。Because this class is not typically used to create an instance of the class, this constructor is typically not called directly but is instead called by a derived class.

此版本的Control构造函数设置初始Text属性值设置为text参数值。This version of the Control constructor sets the initial Text property value to the text parameter value.

Control(Control, String) Control(Control, String) Control(Control, String) Control(Control, String)

用特定文本将 Control 类的新实例初始化为子控件。Initializes a new instance of the Control class as a child control, with specific text.

public:
 Control(System::Windows::Forms::Control ^ parent, System::String ^ text);
public Control (System.Windows.Forms.Control parent, string text);
new System.Windows.Forms.Control : System.Windows.Forms.Control * string -> System.Windows.Forms.Control
Public Sub New (parent As Control, text As String)

参数

parent
Control Control Control Control

要成为该控件的父级的 ControlThe Control to be the parent of the control.

text
String String String String

控件显示的文本。The text displayed by the control.

注解

Control类是在 Windows 窗体应用程序中使用的所有控件的基类。The Control class is the base class for all controls used in a Windows Forms application. 因为该类通常不用于创建类的实例,此构造函数通常不直接调用,但而通过派生类调用。Because this class is not typically used to create an instance of the class, this constructor is typically not called directly but is instead called by a derived class.

此版本的Control构造函数设置初始Text属性值设置为text参数值。This version of the Control constructor sets the initial Text property value to the text parameter value. 构造函数还将控件添加到父控件的Control.ControlCollectionThe constructor also adds the control to the parent control's Control.ControlCollection.

Control(String, Int32, Int32, Int32, Int32) Control(String, Int32, Int32, Int32, Int32) Control(String, Int32, Int32, Int32, Int32) Control(String, Int32, Int32, Int32, Int32)

用特定的文本、大小和位置初始化 Control 类的新实例。Initializes a new instance of the Control class with specific text, size, and location.

public:
 Control(System::String ^ text, int left, int top, int width, int height);
public Control (string text, int left, int top, int width, int height);
new System.Windows.Forms.Control : string * int * int * int * int -> System.Windows.Forms.Control
Public Sub New (text As String, left As Integer, top As Integer, width As Integer, height As Integer)

参数

text
String String String String

控件显示的文本。The text displayed by the control.

left
Int32 Int32 Int32 Int32

控件距其容器左边缘的 X 位置(以像素为单位)。The X position of the control, in pixels, from the left edge of the control's container. 该值被分配给 Left 属性。The value is assigned to the Left property.

top
Int32 Int32 Int32 Int32

控件距其容器上边缘的 Y 位置(以像素为单位)。The Y position of the control, in pixels, from the top edge of the control's container. 该值被分配给 Top 属性。The value is assigned to the Top property.

width
Int32 Int32 Int32 Int32

控件的宽度(以像素为单位)。The width of the control, in pixels. 该值被分配给 Width 属性。The value is assigned to the Width property.

height
Int32 Int32 Int32 Int32

控件的高度(以像素为单位)。The height of the control, in pixels. 该值被分配给 Height 属性。The value is assigned to the Height property.

注解

Control类是在 Windows 窗体应用程序中使用的所有控件的基类。The Control class is the base class for all controls used in a Windows Forms application. 因为该类通常不用于创建类的实例,此构造函数通常不直接调用,但而通过派生类调用。Because this class is not typically used to create an instance of the class, this constructor is typically not called directly but is instead called by a derived class.

此版本的Control构造函数设置初始Text属性值设置为text参数值。This version of the Control constructor sets the initial Text property value to the text parameter value. 初始SizeLocation的控件由lefttopwidthheight参数值。The initial Size and Location of the control are determined by the left, top, width and height parameter values.

备注

若要维护更好的性能,不要在其构造函数中设置控件的大小。To maintain better performance, do not set the size of a control in its constructor. 首选的方法是重写DefaultSize属性。The preferred method is to override the DefaultSize property.

Control(Control, String, Int32, Int32, Int32, Int32) Control(Control, String, Int32, Int32, Int32, Int32) Control(Control, String, Int32, Int32, Int32, Int32) Control(Control, String, Int32, Int32, Int32, Int32)

用特定的文本、大小和位置将 Control 类的新实例初始化为子控件。Initializes a new instance of the Control class as a child control, with specific text, size, and location.

public:
 Control(System::Windows::Forms::Control ^ parent, System::String ^ text, int left, int top, int width, int height);
public Control (System.Windows.Forms.Control parent, string text, int left, int top, int width, int height);
new System.Windows.Forms.Control : System.Windows.Forms.Control * string * int * int * int * int -> System.Windows.Forms.Control
Public Sub New (parent As Control, text As String, left As Integer, top As Integer, width As Integer, height As Integer)

参数

parent
Control Control Control Control

要成为该控件的父级的 ControlThe Control to be the parent of the control.

text
String String String String

控件显示的文本。The text displayed by the control.

left
Int32 Int32 Int32 Int32

控件距其容器左边缘的 X 位置(以像素为单位)。The X position of the control, in pixels, from the left edge of the control's container. 该值被分配给 Left 属性。The value is assigned to the Left property.

top
Int32 Int32 Int32 Int32

控件距其容器上边缘的 Y 位置(以像素为单位)。The Y position of the control, in pixels, from the top edge of the control's container. 该值被分配给 Top 属性。The value is assigned to the Top property.

width
Int32 Int32 Int32 Int32

控件的宽度(以像素为单位)。The width of the control, in pixels. 该值被分配给 Width 属性。The value is assigned to the Width property.

height
Int32 Int32 Int32 Int32

控件的高度(以像素为单位)。The height of the control, in pixels. 该值被分配给 Height 属性。The value is assigned to the Height property.

注解

Control类是在 Windows 窗体应用程序中使用的所有控件的基类。The Control class is the base class for all controls used in a Windows Forms application. 因为该类通常不用于创建类的实例,此构造函数通常不直接调用,但而通过派生类调用。Because this class is not typically used to create an instance of the class, this constructor is typically not called directly but is instead called by a derived class.

此版本的Control构造函数设置初始Text属性值设置为text参数值。This version of the Control constructor sets the initial Text property value to the text parameter value. 构造函数还将控件添加到父控件的Control.ControlCollectionThe constructor also adds the control to the parent control's Control.ControlCollection. 初始SizeLocation的控件由lefttopwidthheight参数值。The initial Size and Location of the control are determined by the left, top, width and height parameter values.

备注

若要维护更好的性能,不要在其构造函数中设置控件的大小。To maintain better performance, do not set the size of a control in its constructor. 首选的方法是重写DefaultSize属性。The preferred method is to override the DefaultSize property.

适用于