次の方法で共有


LineShape.X2 プロパティ

取得または設定によって描画される線の終点の X 座標、LineShapeコントロールです。

名前空間:  Microsoft.VisualBasic.PowerPacks
アセンブリ:  Microsoft.VisualBasic.PowerPacks.Vs (Microsoft.VisualBasic.PowerPacks.Vs.dll 内)

構文

'宣言
<BrowsableAttribute(True)> _
Public Property X2 As Integer
[BrowsableAttribute(true)]
public int X2 { get; set; }
[BrowsableAttribute(true)]
public:
property int X2 {
    int get ();
    void set (int value);
}
[<BrowsableAttribute(true)>]
member X2 : int with get, set
function get X2 () : int 
function set X2 (value : int)

プロパティ値

型 : Int32
Integer を表す線の終点の X (水平方向) 座標。

解説

座標がのコンテナーを基準にして、LineShape制御し、は、ピクセル単位で表されます。

設定して、終了の座標を変更することもできる、EndPointプロパティです。

次の例を変更することで、斜めの線の方向を変更する方法を示しています、 X1Y1、 X2、およびY2プロパティです。

Dim canvas As New Microsoft.VisualBasic.PowerPacks.ShapeContainer
Dim line1 As New Microsoft.VisualBasic.PowerPacks.LineShape(10, 10,
    200, 10)
Private Sub LineDirection_Load(ByVal sender As System.Object,
    ByVal e As System.EventArgs) Handles MyBase.Load
    ' Set the form as the parent of the ShapeContainer.
    canvas.Parent = Me 
    ' Set the ShapeContainer as the parent of the LineShape.
    line1.Parent = canvas
End Sub 
Private Sub LineDirection_Click(ByVal sender As Object,
    ByVal e As System.EventArgs) Handles Me.Click
    ChangeDirection()
End Sub 
Private Sub ChangeDirection()
    If line1.X1 = line1.Y2 Then
        line1.X2 = 10
        line1.Y2 = 200
    Else
        line1.X2 = 200
        line1.Y2 = 10
    End If 
End Sub
Microsoft.VisualBasic.PowerPacks.ShapeContainer canvas = 
    new Microsoft.VisualBasic.PowerPacks.ShapeContainer();
Microsoft.VisualBasic.PowerPacks.LineShape line1 = 
    new Microsoft.VisualBasic.PowerPacks.LineShape(10, 10, 200, 10);
private void LineDirection_Load(System.Object sender, System.EventArgs e)
{
    // Set the form as the parent of the ShapeContainer.
    canvas.Parent = this;
    // Set the ShapeContainer as the parent of the LineShape.
    line1.Parent = canvas;
}
private void LineDirection_Click(object sender, System.EventArgs e)
{
    ChangeDirection();
}
private void ChangeDirection()
{
    if (line1.X1 == line1.Y2)
    {
        line1.X2 = 10;
        line1.Y2 = 200;
    }
    else
    {
        line1.X2 = 200;
        line1.Y2 = 10;
    }
}

.NET Framework セキュリティ

  • 直前の呼び出し元に対する完全な信頼。このメンバーは、部分的に信頼されているコードから使用することはできません。詳細については、「部分信頼コードからのライブラリの使用」を参照してください。

参照

関連項目

LineShape クラス

Microsoft.VisualBasic.PowerPacks 名前空間

ShapeContainer

Shape

その他の技術情報

方法 : OvalShape コントロールおよび RectangleShape コントロールを使用して図形を描画する (Visual Studio)

方法 : LineShape コントロールを使用して線を描画する (Visual Studio)

ライン コントロールとシェイプ コントロールの概要 (Visual Studio)