Point.X 속성
이 Point의 X 좌표를 가져오거나 설정합니다.
네임스페이스: System.Drawing
어셈블리: System.Drawing(system.drawing.dll)
구문
‘선언
Public Property X As Integer
‘사용 방법
Dim instance As Point
Dim value As Integer
value = instance.X
instance.X = value
public int X { get; set; }
public:
property int X {
int get ();
void set (int value);
}
/** @property */
public int get_X ()
/** @property */
public void set_X (int value)
public function get X () : int
public function set X (value : int)
속성 값
이 Point의 X 좌표입니다.
예제
다음 코드 예제에서는 op_Equality 연산자를 사용하는 방법과 Size 또는 두 정수에서 Point를 생성하는 방법을 보여 줍니다. 또한 X 및 Y 속성을 사용하는 방법도 보여 줍니다. 이 예제는 Windows Forms과 함께 사용해야 합니다. Button1
이라는 단추가 포함된 폼에 코드를 붙여넣은 다음 Button1_Click
메서드와 단추의 Click 이벤트를 연결합니다.
Private Sub Button1_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles Button1.Click
' Construct a new Point with integers.
Dim Point1 As New Point(100, 100)
' Create a Graphics object.
Dim formGraphics As Graphics = Me.CreateGraphics()
' Construct another Point, this time using a Size.
Dim Point2 As New Point(New Size(100, 100))
' Call the equality operator to see if the points are equal,
' and if so print out their x and y values.
If (Point.op_Equality(Point1, Point2)) Then
formGraphics.DrawString(String.Format("Point1.X: " & _
"{0},Point2.X: {1}, Point1.Y: {2}, Point2.Y {3}", _
New Object() {Point1.X, Point2.X, Point1.Y, Point2.Y}), _
Me.Font, Brushes.Black, New PointF(10, 70))
End If
End Sub
private void Button1_Click(System.Object sender, System.EventArgs e)
{
// Construct a new Point with integers.
Point Point1 = new Point(100, 100);
// Create a Graphics object.
Graphics formGraphics = this.CreateGraphics();
// Construct another Point, this time using a Size.
Point Point2 = new Point(new Size(100, 100));
// Call the equality operator to see if the points are equal,
// and if so print out their x and y values.
if (Point1 == Point2)
{
formGraphics.DrawString(String.Format("Point1.X: " +
"{0},Point2.X: {1}, Point1.Y: {2}, Point2.Y {3}",
new object[]{Point1.X, Point2.X, Point1.Y, Point2.Y}),
this.Font, Brushes.Black, new PointF(10, 70));
}
}
private:
void Button1_Click( System::Object^ /*sender*/, System::EventArgs^ /*e*/ )
{
// Construct a new Point with integers.
Point Point1 = Point(100,100);
// Create a Graphics object.
Graphics^ formGraphics = this->CreateGraphics();
// Construct another Point, this time using a Size.
Point Point2 = Point(System::Drawing::Size( 100, 100 ));
// Call the equality operator to see if the points are equal,
// and if so print out their x and y values.
if ( Point1 == Point2 )
{
array<Object^>^temp0 = {Point1.X,Point2.X,Point1.Y,Point2.Y};
formGraphics->DrawString( String::Format( "Point1.X: "
"{0},Point2.X: {1}, Point1.Y: {2}, Point2.Y {3}", temp0 ), this->Font, Brushes::Black, PointF(10,70) );
}
}
private void button1_Click(Object sender, System.EventArgs e)
{
// Construct a new Point with integers.
Point point1 = new Point(100, 100);
// Create a Graphics object.
Graphics formGraphics = this.CreateGraphics();
// Construct another Point, this time using a Size.
Point point2 = new Point(new Size(100, 100));
// Call the equality operator to see if the points are equal,
// and if so print out their x and y values.
if (point1.Equals(point2)) {
formGraphics.DrawString(String.Format("Point1.X: "
+ "{0},Point2.X: {1}, Point1.Y: {2}, Point2.Y {3}",
new Object[] { new Integer(point1.get_X()),
new Integer(point2.get_X()), new Integer(point1.get_Y()),
new Integer(point2.get_Y()) }), this.get_Font(),
Brushes.get_Black(), new PointF(10, 70));
}
} //button1_Click
플랫폼
Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
.NET Framework에서 모든 플래폼의 모든 버전을 지원하지는 않습니다. 지원되는 버전의 목록은 시스템 요구 사항을 참조하십시오.
버전 정보
.NET Framework
2.0, 1.1, 1.0에서 지원
.NET Compact Framework
2.0, 1.0에서 지원