Exporter (0) Imprimer
Développer tout
Développer Réduire
Cet article a fait l'objet d'une traduction automatique. Déplacez votre pointeur sur les phrases de l'article pour voir la version originale de ce texte. Informations supplémentaires.
Traduction
Source

Control.Right, propriété

Obtient la distance, in pixels, entre le bord droit du contrôle et le bord gauche de la zone cliente de son conteneur.

Espace de noms :  System.Windows.Forms
Assembly :  System.Windows.Forms (dans System.Windows.Forms.dll)

[BrowsableAttribute(false)]
public int Right { get; }

Valeur de propriété

Type : System.Int32
Int32 représentant la distance, in pixels, entre le bord droit du contrôle et le bord gauche de la zone cliente de son conteneur.

La valeur de la propriété Right est égale à la somme des valeurs des propriétés Left et Width.

La propriété Right est en lecture seule. Vous pouvez modifier la valeur de cette propriété indirectement en modifiant la valeur des propriétés Left ou Width, ou en appelant les méthodes SetBounds, SetBoundsCore, UpdateBounds ou SetClientSizeCore.

L'exemple de code suivant crée trois contrôles Button sur un formulaire, puis définit leur taille et leur emplacement en utilisant les diverses propriétés relatives à la taille et à l'emplacement. Cet exemple suppose que vous disposiez d'un Form d'au moins 300 pixels de largeur et de hauteur.


' Create three buttons and place them on a form using 
' several size and location related properties. 
Private Sub AddOKCancelButtons()
   ' Set the button size and location using 
      ' the Size and Location properties. 
   Dim buttonOK As 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"
   Me.AcceptButton = buttonOK

   ' Set the button size and location using the Top, 
   ' Left, Width, and Height properties. 
   Dim buttonCancel As 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"
   Me.CancelButton = buttonCancel

   ' Set the button size and location using 
   ' the Bounds property. 
   Dim buttonHelp As 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.
   Me.Controls.AddRange(New Control() {buttonOK, buttonCancel, buttonHelp})
End Sub



// 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.
void AddOKCancelButtons()
{

   // Set the button size and location using
   // the Size and Location properties.
   Button^ buttonOK = gcnew Button;
   buttonOK->Location = Point(136,248);
   buttonOK->Size = System::Drawing::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 = gcnew 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 = gcnew Button;
   buttonHelp->Bounds = Rectangle(10,10,75,25);

   // Set the Text property of the button.
   buttonHelp->Text = "&Help";

   // Add the buttons to the form.
   array<Control^>^temp1 = {buttonOK,buttonCancel,buttonHelp};
   this->Controls->AddRange( temp1 );
}



' This example demonstrates how to use the KeyUp event with the Help class to display
' pop-up style help to the user of the application. When the user presses F1, the Help
' class displays a pop-up window, similar to a ToolTip, near the control. This example assumes
' that a TextBox control, named textBox1, has been added to the form and its KeyUp
' event has been contected to this event handler method.
Private Sub textBox1_KeyUp(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles textBox1.KeyUp
    ' Determine whether the key entered is the F1 key. Display help if it is.
    If e.KeyCode = Keys.F1 Then
        ' Display a pop-up help topic to assist the user.
        Help.ShowPopup(textBox1, "Enter your first name", New Point(textBox1.Right, Me.textBox1.Bottom))
    End If
End Sub 'textBox1_KeyUp



// This example demonstrates how to use the KeyUp event with the Help class to display
// pop-up style help to the user of the application. When the user presses F1, the Help
// class displays a pop-up window, similar to a ToolTip, near the control. This example assumes
// that a TextBox control, named textBox1, has been added to the form and its KeyUp
// event has been contected to this event handler method.
private void textBox1_KeyUp(object sender, System.Windows.Forms.KeyEventArgs e)
{
    // Determine whether the key entered is the F1 key. Display help if it is.
    if(e.KeyCode == Keys.F1)
    {
        // Display a pop-up help topic to assist the user.
        Help.ShowPopup(textBox1, "Enter your first name", new Point(textBox1.Right, this.textBox1.Bottom));
    }
}



   // This example demonstrates how to use the KeyUp event with the Help class to display
   // pop-up style help to the user of the application. When the user presses F1, the Help
   // class displays a pop-up window, similar to a ToolTip, near the control. This example assumes
   // that a TextBox control, named textBox1, has been added to the form and its KeyUp
   // event has been connected to this event handler method.
private:
   void textBox1_KeyUp( Object^ /*sender*/, System::Windows::Forms::KeyEventArgs^ e )
   {

      // Determine whether the key entered is the F1 key. Display help if it is.
      if ( e->KeyCode == Keys::F1 )
      {

         // Display a pop-up help topic to assist the user.
         Help::ShowPopup( textBox1, "Enter your first name", Point(textBox1->Right,this->textBox1->Bottom) );
      }
   }


.NET Framework

Pris en charge dans : 4.5.2, 4.5.1, 4.5, 4, 3.5, 3.0, 2.0, 1.1, 1.0

.NET Framework Client Profile

Pris en charge dans : 4, 3.5 SP1

Windows Phone 8.1, Windows Phone 8, Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (rôle principal du serveur non pris en charge), Windows Server 2008 R2 (rôle principal du serveur pris en charge avec SP1 ou version ultérieure ; Itanium non pris en charge)

Le .NET Framework ne prend pas en charge toutes les versions de chaque plateforme. Pour obtenir la liste des versions prises en charge, consultez Configuration requise du .NET Framework.

Ajouts de la communauté

AJOUTER
Afficher:
© 2014 Microsoft