Graphics.Clip Property
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
public:
property System::Drawing::Region ^ Clip { System::Drawing::Region ^ get(); void set(System::Drawing::Region ^ value); };
public System.Drawing.Region Clip { get; set; }
member this.Clip : System.Drawing.Region with get, set
Public Property Clip As Region
Property Value
A Region that limits the portion of this Graphics that is currently available for drawing.
Examples
The following code example demonstrates the use of the Clip property. This example is designed to be used with Windows Forms. Paste the code into a form and call the SetAndFillClip
method when handling the form's Paint event, passing e
as PaintEventArgs.
private:
void SetAndFillClip( PaintEventArgs^ e )
{
// Set the Clip property to a new region.
e->Graphics->Clip = gcnew System::Drawing::Region( Rectangle(10,10,100,200) );
// Fill the region.
e->Graphics->FillRegion( Brushes::LightSalmon, e->Graphics->Clip );
// Demonstrate the clip region by drawing a string
// at the outer edge of the region.
e->Graphics->DrawString( "Outside of Clip", gcnew System::Drawing::Font( "Arial",12.0F,FontStyle::Regular ), Brushes::Black, 0.0F, 0.0F );
}
private void SetAndFillClip(PaintEventArgs e)
{
// Set the Clip property to a new region.
e.Graphics.Clip = new Region(new Rectangle(10, 10, 100, 200));
// Fill the region.
e.Graphics.FillRegion(Brushes.LightSalmon, e.Graphics.Clip);
// Demonstrate the clip region by drawing a string
// at the outer edge of the region.
e.Graphics.DrawString("Outside of Clip", new Font("Arial",
12.0F, FontStyle.Regular), Brushes.Black, 0.0F, 0.0F);
}
Private Sub SetAndFillClip(ByVal e As PaintEventArgs)
' Set the Clip property to a new region.
e.Graphics.Clip = New Region(New Rectangle(10, 10, 100, 200))
' Fill the region.
e.Graphics.FillRegion(Brushes.LightSalmon, e.Graphics.Clip)
' Demonstrate the clip region by drawing a string
' at the outer edge of the region.
e.Graphics.DrawString("Outside of Clip", _
New Font("Arial", 12.0F, FontStyle.Regular), _
Brushes.Black, 0.0F, 0.0F)
End Sub
Remarks
Modifying the Region object returned by the Clip property does not affect subsequent drawing with the Graphics object. To change the clip region, replace the Clip property value with a new Region object. To determine whether the clipping region is infinite, retrieve the Clip property and call its IsInfinite method.
Applies to
.NET
피드백
https://aka.ms/ContentUserFeedback
출시 예정: 2024년 내내 콘텐츠에 대한 피드백 메커니즘으로 GitHub 문제를 단계적으로 폐지하고 이를 새로운 피드백 시스템으로 바꿀 예정입니다. 자세한 내용은 다음을 참조하세요.다음에 대한 사용자 의견 제출 및 보기