Huomautus
Tämän sivun käyttö edellyttää valtuutusta. Voit yrittää kirjautua sisään tai vaihtaa hakemistoa.
Tämän sivun käyttö edellyttää valtuutusta. Voit yrittää vaihtaa hakemistoa.
This example gives a form an elliptical shape that resizes with the form.
Example
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
Compiling the Code
This example requires:
- References to the System.Windows.Forms and System.Drawing namespaces.
This example overrides the OnPaint method to change the shape of the form. To use this code, copy the method declaration as well as the drawing code inside the method.
See also
Tee yhteistyötä kanssamme GitHubissa
Tämän sisällön lähde on GitHubissa, jossa voit myös luoda ja tarkastella ongelmia ja pull-pyyntöjä. Katso lisätietoja osallistujan oppaasta.
.NET Desktop feedback