Rectangle.Offset Rectangle.Offset Rectangle.Offset Rectangle.Offset Method

Definition

Passt die Position dieses Rechtecks um den angegebenen Betrag an.Adjusts the location of this rectangle by the specified amount.

Überlädt

Offset(Point) Offset(Point) Offset(Point) Offset(Point)

Passt die Position dieses Rechtecks um den angegebenen Betrag an.Adjusts the location of this rectangle by the specified amount.

Offset(Int32, Int32) Offset(Int32, Int32) Offset(Int32, Int32) Offset(Int32, Int32)

Passt die Position dieses Rechtecks um den angegebenen Betrag an.Adjusts the location of this rectangle by the specified amount.

Offset(Point) Offset(Point) Offset(Point) Offset(Point)

Passt die Position dieses Rechtecks um den angegebenen Betrag an.Adjusts the location of this rectangle by the specified amount.

public:
 void Offset(System::Drawing::Point pos);
public void Offset (System.Drawing.Point pos);
member this.Offset : System.Drawing.Point -> unit
Public Sub Offset (pos As Point)

Parameter

pos
Point Point Point Point

Betrag für den Offset der Position.Amount to offset the location.

Beispiele

Im folgenden Codebeispiel werden die ContainsMethoden, Offset und und die SystemPens -Klasse veranschaulicht.The following code example demonstrates the Contains, and Offset methods and the SystemPens class. Dieses Beispiel ist für die Verwendung mit einem Windows Form konzipiert.This example is designed for use with a Windows Form. Fügen Sie diesen Code in ein Formular ein, das eine Button1Schaltfläche DrawFirstRectangle mit dem Namen enthält, indem Sie Load den Konstruktor oder die Button1_Click Methode des Formulars aufzurufen Click und die Methode dem-Ereignis der Schaltfläche zuordnen.Paste this code into a form that contains a button named Button1, call DrawFirstRectangle from the form's constructor or Load method, and associate the Button1_Click method with the button's Click event.

private:
   [UIPermission(SecurityAction::Demand, Window=UIPermissionWindow::AllWindows)]
   void DrawFirstRectangle()
   {
      Rectangle rectangle1 = Rectangle(70,70,100,150);
      ControlPaint::DrawReversibleFrame( rectangle1, SystemColors::Highlight, FrameStyle::Thick );
   }

   void Button1_Click( Object^ /*sender*/, EventArgs^ /*e*/ )
   {
      Rectangle rectangle1 = Rectangle(70,70,100,150);

      // Get the bounds of the screen.
      Rectangle screenRectangle = Screen::PrimaryScreen->Bounds;

      // Check to see if the rectangle is within the bounds of the screen.
      if ( screenRectangle.Contains( rectangle1 ) )
      {
         ControlPaint::DrawReversibleFrame( rectangle1, SystemColors::Highlight, FrameStyle::Thick );

         // Call the Offset method to move the rectangle.
         rectangle1.Offset( 20, 20 );

         // Draw the new, offset rectangle.
         ControlPaint::DrawReversibleFrame( rectangle1, SystemColors::Highlight, FrameStyle::Thick );
      }
   }
Rectangle rectangle1 = new Rectangle(70, 70, 100, 150);

private void DrawFirstRectangle()
{
    ControlPaint.DrawReversibleFrame(rectangle1, 
        SystemColors.Highlight, FrameStyle.Thick);
}

private void Button1_Click(object sender, EventArgs e)
{

    // Get the bounds of the screen.
    Rectangle screenRectangle = Screen.PrimaryScreen.Bounds;

    // Check to see if the rectangle is within the bounds of the screen.
    if (screenRectangle.Contains(rectangle1))

        // If so, erase the previous rectangle.
    {
        ControlPaint.DrawReversibleFrame(rectangle1, 
            SystemColors.Highlight, FrameStyle.Thick);

        // Call the Offset method to move the rectangle.
        rectangle1.Offset(20, 20);

        // Draw the new, offset rectangle.
        ControlPaint.DrawReversibleFrame(rectangle1, 
            SystemColors.Highlight, FrameStyle.Thick);
    }
}
Dim rectangle1 As New Rectangle(70, 70, 100, 150)

Private Sub DrawFirstRectangle()
    ControlPaint.DrawReversibleFrame(rectangle1, _
        SystemColors.Highlight, FrameStyle.Thick)
End Sub

Private Sub Button1_Click(ByVal sender As Object, _
    ByVal e As EventArgs) Handles Button1.Click

    ' Get the bounds of the screen.
    Dim screenRectangle As Rectangle = Screen.PrimaryScreen.Bounds

    ' Check to see if the rectangle is within the bounds of the screen.
    If (screenRectangle.Contains(rectangle1)) Then

        ' If so, erase the previous rectangle.
        ControlPaint.DrawReversibleFrame(rectangle1, _
            SystemColors.Highlight, FrameStyle.Thick)

        ' Call the Offset method to move the rectangle.
        rectangle1.Offset(20, 20)

        ' Draw the new, offset rectangle.
        ControlPaint.DrawReversibleFrame(rectangle1, _
            SystemColors.Highlight, FrameStyle.Thick)
    End If
End Sub

Hinweise

Diese Methode passt die Position der linken oberen Ecke horizontal um die x-Koordinate des angegebenen Punkts und vertikal durch die y-Koordinate des angegebenen Punkts an.This method adjusts the location of the upper-left corner horizontally by the x-coordinate of the specified point, and vertically by the y-coordinate of the specified point.

Offset(Int32, Int32) Offset(Int32, Int32) Offset(Int32, Int32) Offset(Int32, Int32)

Passt die Position dieses Rechtecks um den angegebenen Betrag an.Adjusts the location of this rectangle by the specified amount.

public:
 void Offset(int x, int y);
public void Offset (int x, int y);
member this.Offset : int * int -> unit
Public Sub Offset (x As Integer, y As Integer)

Parameter

x
Int32 Int32 Int32 Int32

Der horizontale Offset.The horizontal offset.

y
Int32 Int32 Int32 Int32

Der vertikale Offset.The vertical offset.

Gilt für: