Export (0) Print
Expand All

Point::X Property

Gets or sets the x-coordinate of this Point.

Namespace:  System.Drawing
Assembly:  System.Drawing (in System.Drawing.dll)

property int X {
	int get ();
	void set (int value);

Property Value

Type: System::Int32
The x-coordinate of this Point.

The following code example demonstrates how to use the Equality operator and how to construct a Point from a Size or two integers. It also demonstrates how to use the X and Y properties. This example is designed to be used with Windows Forms. Paste the code into a form that contains a button named Button1, and associate the Button1_Click method with the button's Click event.

   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) );

.NET Framework

Supported in: 4.6, 4.5, 4, 3.5, 3.0, 2.0, 1.1

.NET Framework Client Profile

Supported in: 4, 3.5 SP1
© 2015 Microsoft