Share via


Control 建構函式

定義

初始化 Control 類別的新執行個體。

多載

Control()

初始化具有預設設定之 Control 類別的新執行個體。

Control(String)

以特定文字初始化 Control 類別的新執行個體。

Control(Control, String)

以特定文字將 Control 類別的新執行個體初始化為子控制項。

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

以特定文字、大小和位置初始化 Control 類別的新執行個體。

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

以特定文字、大小和位置,將 Control 類別的新執行個體初始化為子控制項。

Control()

初始化具有預設設定之 Control 類別的新執行個體。

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

備註

類別 Control 是Windows Forms應用程式中使用之所有控制項的基類。 因為這個類別通常不會用來建立 類別的實例,所以這個建構函式通常不會直接呼叫,而是由衍生類別呼叫。

適用於

Control(String)

以特定文字初始化 Control 類別的新執行個體。

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

參數

text
String

由控制項顯示的文字。

備註

類別 Control 是Windows Forms應用程式中使用之所有控制項的基類。 因為這個類別通常不會用來建立 類別的實例,所以這個建構函式通常不會直接呼叫,而是由衍生類別呼叫。

這個版本的 Control 建構函式會將初始 Text 屬性值設定為 text 參數值。

適用於

Control(Control, String)

以特定文字將 Control 類別的新執行個體初始化為子控制項。

public:
 Control(System::Windows::Forms::Control ^ parent, System::String ^ text);
public Control (System.Windows.Forms.Control parent, 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

text
String

由控制項顯示的文字。

備註

類別 Control 是Windows Forms應用程式中使用之所有控制項的基類。 因為這個類別通常不會用來建立 類別的實例,所以這個建構函式通常不會直接呼叫,而是由衍生類別呼叫。

這個版本的 Control 建構函式會將初始 Text 屬性值設定為 text 參數值。 建構函式也會將 控制項加入父控制項的 Control.ControlCollection

適用於

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

以特定文字、大小和位置初始化 Control 類別的新執行個體。

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);
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

由控制項顯示的文字。

left
Int32

控制項的 X 位置,從控制項容器的左邊緣開始,單位為像素。 這個值被指派給 Left 屬性。

top
Int32

控制項的 Y 位置,從控制項容器的上邊緣開始,單位為像素。 這個值被指派給 Top 屬性。

width
Int32

控制項的寬度 (單位為像素)。 這個值被指派給 Width 屬性。

height
Int32

控制項的高度 (單位為像素)。 這個值被指派給 Height 屬性。

備註

類別 Control 是Windows Forms應用程式中使用之所有控制項的基類。 因為這個類別通常不會用來建立 類別的實例,所以這個建構函式通常不會直接呼叫,而是由衍生類別呼叫。

這個版本的 Control 建構函式會將初始 Text 屬性值設定為 text 參數值。 控制項的初始 SizeLocation 是由 、 top widthheight 參數值所決定 left

注意

若要維持較佳的效能,請勿在其建構函式中設定控制項的大小。 慣用的方法是覆寫 DefaultSize 屬性。

適用於

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

以特定文字、大小和位置,將 Control 類別的新執行個體初始化為子控制項。

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);
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

text
String

由控制項顯示的文字。

left
Int32

控制項的 X 位置,從控制項容器的左邊緣開始,單位為像素。 這個值被指派給 Left 屬性。

top
Int32

控制項的 Y 位置,從控制項容器的上邊緣開始,單位為像素。 這個值被指派給 Top 屬性。

width
Int32

控制項的寬度 (單位為像素)。 這個值被指派給 Width 屬性。

height
Int32

控制項的高度 (單位為像素)。 這個值被指派給 Height 屬性。

備註

類別 Control 是Windows Forms應用程式中使用之所有控制項的基類。 因為這個類別通常不會用來建立 類別的實例,所以這個建構函式通常不會直接呼叫,而是由衍生類別呼叫。

這個版本的 Control 建構函式會將初始 Text 屬性值設定為 text 參數值。 建構函式也會將 控制項加入父控制項的 Control.ControlCollection 。 控制項的初始 SizeLocation 是由 、 top widthheight 參數值所決定 left

注意

若要維持較佳的效能,請勿在其建構函式中設定控制項的大小。 慣用的方法是覆寫 DefaultSize 屬性。

適用於