This documentation is archived and is not being maintained.

Graphics.TranslateClip Method

Translates the clipping region of this Graphics object by specified amounts in the horizontal and vertical directions.

Overload List

Translates the clipping region of this Graphics object by specified amounts in the horizontal and vertical directions.

[Visual Basic] Overloads Public Sub TranslateClip(Integer, Integer)
[C#] public void TranslateClip(int, int);
[C++] public: void TranslateClip(int, int);
[JScript] public function TranslateClip(int, int);

Translates the clipping region of this Graphics object by specified amounts in the horizontal and vertical directions.

[Visual Basic] Overloads Public Sub TranslateClip(Single, Single)
[C#] public void TranslateClip(float, float);
[C++] public: void TranslateClip(float, float);
[JScript] public function TranslateClip(float, float);

Example

[Visual Basic, C#] The following example is designed for use with Windows Forms, and it requires PaintEventArgs e, which is a parameter of the Paint event handler. The code performs the following actions:

  • Creates a rectangle for the clipping region.
  • Sets the clipping region to the rectangle.
  • Translates the clipping region by a vector (50.0F, 50.0F).
  • Fills a large rectangle with a solid black brush.

[Visual Basic, C#] The result is a translated, small, black rectangle.

[Visual Basic, C#] Note   This example shows how to use one of the overloaded versions of TranslateClip. For other examples that might be available, see the individual overload topics.
[Visual Basic] 
Public Sub TranslateClipFloat(e As PaintEventArgs)
' Create rectangle for clipping region.
Dim clipRect As New RectangleF(0F, 0F, 100F, 100F)
' Set clipping region of graphics to rectangle.
e.Graphics.SetClip(clipRect)
' Translate clipping region.
Dim dx As Single = 50F
Dim dy As Single = 50F
e.Graphics.TranslateClip(dx, dy)
' Fill rectangle to demonstrate translated clip region.
e.Graphics.FillRectangle(New SolidBrush(Color.Black), 0, 0, _
500, 300)
End Sub
        
[C#] 
public void TranslateClipFloat(PaintEventArgs e)
{
// Create rectangle for clipping region.
RectangleF clipRect = new RectangleF(0.0F, 0.0F, 100.0F, 100.0F);
// Set clipping region of graphics to rectangle.
e.Graphics.SetClip(clipRect);
// Translate clipping region.
float dx = 50.0F;
float dy = 50.0F;
e.Graphics.TranslateClip(dx, dy);
// Fill rectangle to demonstrate translated clip region.
e.Graphics.FillRectangle(new SolidBrush(Color.Black), 0, 0, 500, 300);
}
        

[C++, JScript] No example is available for C++ or JScript. To view a Visual Basic or C# example, click the Language Filter button Language Filter in the upper-left corner of the page.

See Also

Graphics Class | Graphics Members | System.Drawing Namespace

Show: