Control.Height-Eigenschaft
.NET Framework 3.5
Aktualisiert: November 2007
Ruft die Höhe des Steuerelements ab oder legt diese fest.
Assembly: System.Windows.Forms (in System.Windows.Forms.dll)
Im folgenden Codebeispiel werden drei Button-Steuerelemente in einem Formular erstellt und mehrere entsprechende Eigenschaften zum Festlegen von Größe und Position verwendet. Bei diesem Beispiel muss ein Form mit einer Höhe und Breite von mindestens 300 Pixel vorhanden sein.
// Create three buttons and place them on a form using // several size and location related properties. private void AddOKCancelButtons() { // Set the button size and location using // the Size and Location properties. Button buttonOK = new Button(); buttonOK.Location = new Point(136,248); buttonOK.Size = new Size(75,25); // Set the Text property and make the // button the form's default button. buttonOK.Text = "&OK"; this.AcceptButton = buttonOK; // Set the button size and location using the Top, // Left, Width, and Height properties. Button buttonCancel = new Button(); buttonCancel.Top = buttonOK.Top; buttonCancel.Left = buttonOK.Right + 5; buttonCancel.Width = buttonOK.Width; buttonCancel.Height = buttonOK.Height; // Set the Text property and make the // button the form's cancel button. buttonCancel.Text = "&Cancel"; this.CancelButton = buttonCancel; // Set the button size and location using // the Bounds property. Button buttonHelp = new Button(); buttonHelp.Bounds = new Rectangle(10,10, 75, 25); // Set the Text property of the button. buttonHelp.Text = "&Help"; // Add the buttons to the form. this.Controls.AddRange(new Control[] {buttonOK, buttonCancel, buttonHelp} ); }
// Create three buttons and place them on a form using
// several size and location related properties.
private void AddOKCancelButtons()
{
// Set the button size and location using
// the Size and Location properties.
Button buttonOK = new Button();
buttonOK.set_Location(new Point(136, 248));
buttonOK.set_Size(new Size(75, 25));
// Set the Text property and make the
// button the form's default button.
buttonOK.set_Text("&OK");
this.set_AcceptButton(buttonOK);
// Set the button size and location using the Top,
// Left, Width, and Height properties.
Button buttonCancel = new Button();
buttonCancel.set_Top(buttonOK.get_Top());
buttonCancel.set_Left(buttonOK.get_Right() + 5);
buttonCancel.set_Width(buttonOK.get_Width());
buttonCancel.set_Height(buttonOK.get_Height());
// Set the Text property and make the
// button the form's cancel button.
buttonCancel.set_Text("&Cancel");
this.set_CancelButton(buttonCancel);
// Set the button size and location using
// the Bounds property.
Button buttonHelp = new Button();
buttonHelp.set_Bounds(new Rectangle(10, 10, 75, 25));
// Set the Text property of the button.
buttonHelp.set_Text("&Help");
// Add the buttons to the form.
this.get_Controls().AddRange(new Control[] { buttonOK, buttonCancel,
buttonHelp });
} //AddOKCancelButtons
Windows Vista, Windows XP SP2, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP Starter Edition, Windows Server 2003, Windows Server 2000 SP4, Windows Millennium Edition, Windows 98, Windows CE, Windows Mobile für Smartphone, Windows Mobile für Pocket PC
.NET Framework und .NET Compact Framework unterstützen nicht alle Versionen sämtlicher Plattformen. Eine Liste der unterstützten Versionen finden Sie unter Systemanforderungen für .NET Framework.
Hinweis: