Graphics.DrawLine Graphics.DrawLine Graphics.DrawLine Method

정의

좌표 쌍에 의해 지정된 두 개의 점을 연결하는 선을 그립니다.Draws a line connecting the two points specified by the coordinate pairs.

오버로드

DrawLine(Pen, PointF, PointF) DrawLine(Pen, PointF, PointF) DrawLine(Pen, PointF, PointF)

두 개의 PointF 구조체를 연결하는 선을 그립니다.Draws a line connecting two PointF structures.

DrawLine(Pen, Int32, Int32, Int32, Int32) DrawLine(Pen, Int32, Int32, Int32, Int32) DrawLine(Pen, Int32, Int32, Int32, Int32)

좌표 쌍에 의해 지정된 두 개의 점을 연결하는 선을 그립니다.Draws a line connecting the two points specified by the coordinate pairs.

DrawLine(Pen, Single, Single, Single, Single) DrawLine(Pen, Single, Single, Single, Single) DrawLine(Pen, Single, Single, Single, Single)

좌표 쌍에 의해 지정된 두 개의 점을 연결하는 선을 그립니다.Draws a line connecting the two points specified by the coordinate pairs.

DrawLine(Pen, Point, Point) DrawLine(Pen, Point, Point) DrawLine(Pen, Point, Point)

두 개의 Point 구조체를 연결하는 선을 그립니다.Draws a line connecting two Point structures.

DrawLine(Pen, PointF, PointF) DrawLine(Pen, PointF, PointF) DrawLine(Pen, PointF, PointF)

두 개의 PointF 구조체를 연결하는 선을 그립니다.Draws a line connecting two PointF structures.

public:
 void DrawLine(System::Drawing::Pen ^ pen, System::Drawing::PointF pt1, System::Drawing::PointF pt2);
public void DrawLine (System.Drawing.Pen pen, System.Drawing.PointF pt1, System.Drawing.PointF pt2);
member this.DrawLine : System.Drawing.Pen * System.Drawing.PointF * System.Drawing.PointF -> unit

매개 변수

pen
Pen Pen Pen

선의 색, 너비 및 스타일을 결정하는 Pen입니다.Pen that determines the color, width, and style of the line.

pt1
PointF PointF PointF

연결할 첫째 점을 나타내는 PointF 구조체입니다.PointF structure that represents the first point to connect.

pt2
PointF PointF PointF

연결할 둘째 점을 나타내는 PointF 구조체입니다.PointF structure that represents the second point to connect.

예외

예제

다음 코드 예제는 Windows Forms에서 사용 하도록 설계 되었으며 필요 PaintEventArgs e의 매개 변수는 Paint 이벤트 처리기입니다.The following code example is designed for use with Windows Forms, and it requires PaintEventArgse, which is a parameter of the Paint event handler. 이 코드에서는 다음 작업을 수행합니다.The code performs the following actions:

  • Black 펜을 만듭니다.Creates a black pen.

  • 선의 끝점에 대 한 끝점을 만듭니다.Creates points for the endpoints of the line.

  • 화면에 선을 그립니다.Draws the line to the screen.

public:
   void DrawLinePointF( PaintEventArgs^ e )
   {

      // Create pen.
      Pen^ blackPen = gcnew Pen( Color::Black,3.0f );
      
      // Create points that define line.
      PointF point1 = PointF(100.0F,100.0F);
      PointF point2 = PointF(500.0F,100.0F);

      // Draw line to screen.
      e->Graphics->DrawLine( blackPen, point1, point2 );
   }
public void DrawLinePointF(PaintEventArgs e)
{
             
    // Create pen.
    Pen blackPen = new Pen(Color.Black, 3);
             
    // Create points that define line.
    PointF point1 = new PointF(100.0F, 100.0F);
    PointF point2 = new PointF(500.0F, 100.0F);
             
    // Draw line to screen.
    e.Graphics.DrawLine(blackPen, point1, point2);
}
Public Sub DrawLinePointF(ByVal e As PaintEventArgs)

    ' Create pen.
    Dim blackPen As New Pen(Color.Black, 3)

    ' Create points that define line.
    Dim point1 As New PointF(100.0F, 100.0F)
    Dim point2 As New PointF(500.0F, 100.0F)

    ' Draw line to screen.
    e.Graphics.DrawLine(blackPen, point1, point2)
End Sub

설명

이 메서드는 지정 된 두 지점을 연결 선을 그립니다 합니다 pt1 및 p2 매개 변수입니다.This method draws a line connecting the two points specified by the pt1 and p2 parameters.

추가 정보

DrawLine(Pen, Int32, Int32, Int32, Int32) DrawLine(Pen, Int32, Int32, Int32, Int32) DrawLine(Pen, Int32, Int32, Int32, Int32)

좌표 쌍에 의해 지정된 두 개의 점을 연결하는 선을 그립니다.Draws a line connecting the two points specified by the coordinate pairs.

public:
 void DrawLine(System::Drawing::Pen ^ pen, int x1, int y1, int x2, int y2);
public void DrawLine (System.Drawing.Pen pen, int x1, int y1, int x2, int y2);
member this.DrawLine : System.Drawing.Pen * int * int * int * int -> unit

매개 변수

pen
Pen Pen Pen

선의 색, 너비 및 스타일을 결정하는 Pen입니다.Pen that determines the color, width, and style of the line.

x1
Int32 Int32 Int32

첫째 점의 X좌표입니다.The x-coordinate of the first point.

y1
Int32 Int32 Int32

첫째 점의 Y좌표입니다.The y-coordinate of the first point.

x2
Int32 Int32 Int32

둘째 점의 X좌표입니다.The x-coordinate of the second point.

y2
Int32 Int32 Int32

둘째 점의 Y좌표입니다.The y-coordinate of the second point.

예외

예제

다음 코드 예제는 Windows Forms에서 사용 하도록 설계 되었으며 필요 PaintEventArgs e의 매개 변수는 Paint 이벤트 처리기입니다.The following code example is designed for use with Windows Forms, and it requires PaintEventArgse, which is a parameter of the Paint event handler. 이 코드에서는 다음 작업을 수행합니다.The code performs the following actions:

  • Black 펜을 만듭니다.Creates a black pen.

  • 선의 끝점 좌표를 만듭니다.Creates the coordinates of the endpoints of the line.

  • 화면에 선을 그립니다.Draws the line to the screen.

public:
   void DrawLineInt( PaintEventArgs^ e )
   {
      // Create pen.
      Pen^ blackPen = gcnew Pen( Color::Black,3.0f );

      // Create coordinates of points that define line.
      int x1 = 100;
      int y1 = 100;
      int x2 = 500;
      int y2 = 100;

      // Draw line to screen.
      e->Graphics->DrawLine( blackPen, x1, y1, x2, y2 );
   }
public void DrawLineInt(PaintEventArgs e)
{
             
    // Create pen.
    Pen blackPen = new Pen(Color.Black, 3);
             
    // Create coordinates of points that define line.
    int x1 = 100;
    int y1 = 100;
    int x2 = 500;
    int y2 = 100;
             
    // Draw line to screen.
    e.Graphics.DrawLine(blackPen, x1, y1, x2, y2);
}
Public Sub DrawLineInt(ByVal e As PaintEventArgs)

    ' Create pen.
    Dim blackPen As New Pen(Color.Black, 3)

    ' Create coordinates of points that define line.
    Dim x1 As Integer = 100
    Dim y1 As Integer = 100
    Dim x2 As Integer = 500
    Dim y2 As Integer = 100

    ' Draw line to screen.
    e.Graphics.DrawLine(blackPen, x1, y1, x2, y2)
End Sub

설명

이 메서드는 지정 된 두 지점을 연결 선을 그립니다 합니다 x1, y1x2, 및 y2 매개 변수입니다.This method draws a line connecting the two points specified by the x1, y1, x2, and y2 parameters.

추가 정보

DrawLine(Pen, Single, Single, Single, Single) DrawLine(Pen, Single, Single, Single, Single) DrawLine(Pen, Single, Single, Single, Single)

좌표 쌍에 의해 지정된 두 개의 점을 연결하는 선을 그립니다.Draws a line connecting the two points specified by the coordinate pairs.

public:
 void DrawLine(System::Drawing::Pen ^ pen, float x1, float y1, float x2, float y2);
public void DrawLine (System.Drawing.Pen pen, float x1, float y1, float x2, float y2);
member this.DrawLine : System.Drawing.Pen * single * single * single * single -> unit

매개 변수

pen
Pen Pen Pen

선의 색, 너비 및 스타일을 결정하는 Pen입니다.Pen that determines the color, width, and style of the line.

x1
Single Single Single

첫째 점의 X좌표입니다.The x-coordinate of the first point.

y1
Single Single Single

첫째 점의 Y좌표입니다.The y-coordinate of the first point.

x2
Single Single Single

둘째 점의 X좌표입니다.The x-coordinate of the second point.

y2
Single Single Single

둘째 점의 Y좌표입니다.The y-coordinate of the second point.

예외

예제

다음 코드 예제는 Windows Forms에서 사용 하도록 설계 되었으며 필요 PaintEventArgs e의 매개 변수는 Paint 이벤트 처리기입니다.The following code example is designed for use with Windows Forms, and it requires PaintEventArgse, which is a parameter of the Paint event handler. 이 코드에서는 다음 작업을 수행합니다.The code performs the following actions:

  • Black 펜을 만듭니다.Creates a black pen.

  • 선의 끝점 좌표를 만듭니다.Creates the coordinates of the endpoints of the line.

  • 화면에 선을 그립니다.Draws the line to the screen.

public:
   void DrawLineFloat( PaintEventArgs^ e )
   {
      // Create pen.
      Pen^ blackPen = gcnew Pen( Color::Black,3.0f );

      // Create coordinates of points that define line.
      float x1 = 100.0F;
      float y1 = 100.0F;
      float x2 = 500.0F;
      float y2 = 100.0F;

      // Draw line to screen.
      e->Graphics->DrawLine( blackPen, x1, y1, x2, y2 );
   }
public void DrawLineFloat(PaintEventArgs e)
{
             
    // Create pen.
    Pen blackPen = new Pen(Color.Black, 3);
             
    // Create coordinates of points that define line.
    float x1 = 100.0F;
    float y1 = 100.0F;
    float x2 = 500.0F;
    float y2 = 100.0F;
             
    // Draw line to screen.
    e.Graphics.DrawLine(blackPen, x1, y1, x2, y2);
}
Public Sub DrawLineFloat(ByVal e As PaintEventArgs)

    ' Create pen.
    Dim blackPen As New Pen(Color.Black, 3)

    ' Create coordinates of points that define line.
    Dim x1 As Single = 100.0F
    Dim y1 As Single = 100.0F
    Dim x2 As Single = 500.0F
    Dim y2 As Single = 100.0F

    ' Draw line to screen.
    e.Graphics.DrawLine(blackPen, x1, y1, x2, y2)
End Sub

설명

이 메서드는 지정 된 두 지점을 연결 선을 그립니다 합니다 x1, y1x2, 및 y2 매개 변수입니다.This method draws a line connecting the two points specified by the x1, y1, x2, and y2 parameters.

추가 정보

DrawLine(Pen, Point, Point) DrawLine(Pen, Point, Point) DrawLine(Pen, Point, Point)

두 개의 Point 구조체를 연결하는 선을 그립니다.Draws a line connecting two Point structures.

public:
 void DrawLine(System::Drawing::Pen ^ pen, System::Drawing::Point pt1, System::Drawing::Point pt2);
public void DrawLine (System.Drawing.Pen pen, System.Drawing.Point pt1, System.Drawing.Point pt2);
member this.DrawLine : System.Drawing.Pen * System.Drawing.Point * System.Drawing.Point -> unit

매개 변수

pen
Pen Pen Pen

선의 색, 너비 및 스타일을 결정하는 Pen입니다.Pen that determines the color, width, and style of the line.

pt1
Point Point Point

연결할 첫째 점을 나타내는 Point 구조체입니다.Point structure that represents the first point to connect.

pt2
Point Point Point

연결할 둘째 점을 나타내는 Point 구조체입니다.Point structure that represents the second point to connect.

예외

예제

다음 코드 예제는 Windows Forms에서 사용 하도록 설계 되었으며 필요 PaintEventArgs e의 매개 변수는 Paint 이벤트 처리기입니다.The following code example is designed for use with Windows Forms, and it requires PaintEventArgse, which is a parameter of the Paint event handler. 이 코드에서는 다음 작업을 수행합니다.The code performs the following actions:

  • Black 펜을 만듭니다.Creates a black pen.

  • 선의 끝점에 대 한 끝점을 만듭니다.Creates points for the endpoints of the line.

  • 화면에 선을 그립니다.Draws the line to the screen.

public:
   void DrawLinePoint( PaintEventArgs^ e )
   {
      // Create pen.
      Pen^ blackPen = gcnew Pen( Color::Black,3.0f );

      // Create points that define line.
      Point point1 = Point(100,100);
      Point point2 = Point(500,100);

      // Draw line to screen.
      e->Graphics->DrawLine( blackPen, point1, point2 );
   }
public void DrawLinePoint(PaintEventArgs e)
{
             
    // Create pen.
    Pen blackPen = new Pen(Color.Black, 3);
             
    // Create points that define line.
    Point point1 = new Point(100, 100);
    Point point2 = new Point(500, 100);
             
    // Draw line to screen.
    e.Graphics.DrawLine(blackPen, point1, point2);
}
Public Sub DrawLinePoint(ByVal e As PaintEventArgs)

    ' Create pen.
    Dim blackPen As New Pen(Color.Black, 3)

    ' Create points that define line.
    Dim point1 As New Point(100, 100)
    Dim point2 As New Point(500, 100)

    ' Draw line to screen.
    e.Graphics.DrawLine(blackPen, point1, point2)
End Sub
추가 정보

적용 대상