Control.SetBounds Méthode
Définition
Important
Certaines informations portent sur la préversion du produit qui est susceptible d’être en grande partie modifiée avant sa publication. Microsoft exclut toute garantie, expresse ou implicite, concernant les informations fournies ici.
Définit les limites du contrôle.
Surcharges
SetBounds(Int32, Int32, Int32, Int32) |
Définit les limites du contrôle à l'emplacement et à la taille spécifiés. |
SetBounds(Int32, Int32, Int32, Int32, BoundsSpecified) |
Définit les limites spécifiées du contrôle à l'emplacement et à la taille spécifiés. |
SetBounds(Int32, Int32, Int32, Int32)
Définit les limites du contrôle à l'emplacement et à la taille spécifiés.
public:
void SetBounds(int x, int y, int width, int height);
public void SetBounds (int x, int y, int width, int height);
member this.SetBounds : int * int * int * int -> unit
Public Sub SetBounds (x As Integer, y As Integer, width As Integer, height As Integer)
Paramètres
Voir aussi
S’applique à
SetBounds(Int32, Int32, Int32, Int32, BoundsSpecified)
Définit les limites spécifiées du contrôle à l'emplacement et à la taille spécifiés.
public:
void SetBounds(int x, int y, int width, int height, System::Windows::Forms::BoundsSpecified specified);
public void SetBounds (int x, int y, int width, int height, System.Windows.Forms.BoundsSpecified specified);
member this.SetBounds : int * int * int * int * System.Windows.Forms.BoundsSpecified -> unit
Public Sub SetBounds (x As Integer, y As Integer, width As Integer, height As Integer, specified As BoundsSpecified)
Paramètres
- specified
- BoundsSpecified
Combinaison d’opérations de bits des valeurs BoundsSpecified. Pour tout paramètre non spécifié, la valeur actuelle sera utilisée.
Exemples
L’exemple de code suivant centre un Form sur l’écran dans l’événement Layout . Cela permet de garder le formulaire centré à mesure que l’utilisateur le redimensionne. Cet exemple nécessite que vous ayez créé un Form contrôle.
private:
void MyForm_Layout( Object^ /*sender*/, System::Windows::Forms::LayoutEventArgs^ /*e*/ )
{
// Center the Form on the user's screen everytime it requires a Layout.
this->SetBounds( (Screen::GetBounds( this ).Width / 2) - (this->Width / 2), (Screen::GetBounds( this ).Height / 2) - (this->Height / 2), this->Width, this->Height, BoundsSpecified::Location );
}
private void MyForm_Layout(object sender, System.Windows.Forms.LayoutEventArgs e)
{
// Center the Form on the user's screen everytime it requires a Layout.
this.SetBounds((Screen.GetBounds(this).Width/2) - (this.Width/2),
(Screen.GetBounds(this).Height/2) - (this.Height/2),
this.Width, this.Height, BoundsSpecified.Location);
}
Private Sub MyForm_Layout(ByVal sender As Object, _
ByVal e As System.Windows.Forms.LayoutEventArgs) Handles MyBase.Layout
' Center the Form on the user's screen everytime it requires a Layout.
Me.SetBounds((System.Windows.Forms.Screen.GetBounds(Me).Width / 2) - (Me.Width / 2), _
(System.Windows.Forms.Screen.GetBounds(Me).Height / 2) - (Me.Height / 2), _
Me.Width, Me.Height, System.Windows.Forms.BoundsSpecified.Location)
End Sub
Voir aussi
S’applique à
Commentaires
https://aka.ms/ContentUserFeedback.
Bientôt disponible : Tout au long de l’année 2024, nous abandonnerons progressivement le mécanisme de retour d’information GitHub Issues pour le remplacer par un nouveau système de commentaires. Pour plus d’informations, consultez :Soumettre et afficher des commentaires pour