Procedura: Creare un Windows Form con forma
In questo esempio viene fornita una forma ellittica che viene ridimensionata con il form.
Esempio
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);
}
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 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
Compilazione del codice
Questo esempio richiede:
- Riferimenti agli spazi dei nomi System.Windows.Forms e System.Drawing.
In questo esempio viene eseguito l'override del metodo OnPaint per modificare la forma del form. Per usare questo codice, copiare la dichiarazione del metodo e il codice di disegno all'interno del metodo .
Vedere anche
Collabora con noi su GitHub
L'origine di questo contenuto è disponibile in GitHub, in cui è anche possibile creare ed esaminare i problemi e le richieste pull. Per ulteriori informazioni, vedere la guida per i collaboratori.
.NET Desktop feedback