Point.Y 属性
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
获取或设置此 Point 的 y 坐标。
public:
property int Y { int get(); void set(int value); };
public int Y { get; set; }
member this.Y : int with get, set
Public Property Y As Integer
属性值
此 Point 的 y 坐标。
示例
下面的代码示例演示如何使用 Equality 运算符,以及如何从一个或两个PointSize整数构造 。 它还演示如何使用 X 和 Y 属性。 此示例旨在与 Windows 窗体 一起使用。 将代码粘贴到包含名为 的Button1
按钮的窗体中,并将 方法与按钮的事件Click相关联Button1_Click
。
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(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 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