Comment : créer un Windows Form mis en forme

Cet exemple donne au formulaire une forme elliptique dont les dimensions sont déterminées par le formulaire.

Exemple

 Protected Overrides Sub OnPaint( _
ByVal e As System.Windows.Forms.PaintEventArgs)
     Dim shape As New System.Drawing.Drawing2D.GraphicsPath
     shape.AddEllipse(0, 0, Me.Width, Me.Height)
     Me.Region = New System.Drawing.Region(shape)
 End Sub
protected override void OnPaint(System.Windows.Forms.PaintEventArgs e)
{
    System.Drawing.Drawing2D.GraphicsPath shape = new System.Drawing.Drawing2D.GraphicsPath();
    shape.AddEllipse(0, 0, this.Width, this.Height);
    this.Region = new System.Drawing.Region(shape);
}
protected:
    virtual void OnPaint(
        System::Windows::Forms::PaintEventArgs^ e) override
    {
        System::Drawing::Drawing2D::GraphicsPath^ shape =
            gcnew System::Drawing::Drawing2D::GraphicsPath();
        shape->AddEllipse(0, 0, this->Width, this->Height);
        this->Region = gcnew System::Drawing::Region(shape);
    }

Compilation du code

Cet exemple nécessite :

Cet exemple substitue la méthode OnPaint pour modifier la forme du formulaire. Pour utiliser ce code, copiez la déclaration de méthode et le code de dessin à l'intérieur de la méthode.

Voir aussi

Référence

OnPaint

Region

System.Drawing

AddEllipse

Region

Autres ressources

Mise en route de la programmation graphique