LineShape.Y2 Property
Gets or sets the Y coordinate of the ending point of a line drawn by a LineShape control.
Namespace: Microsoft.VisualBasic.PowerPacks
Assembly: Microsoft.VisualBasic.PowerPacks.Vs (in Microsoft.VisualBasic.PowerPacks.Vs.dll)
Syntax
'Declaration
<BrowsableAttribute(True)> _
Public Property Y2 As Integer
'Usage
Dim instance As LineShape
Dim value As Integer
value = instance.Y2
instance.Y2 = value
[BrowsableAttribute(true)]
public int Y2 { get; set; }
[BrowsableAttribute(true)]
public:
property int Y2 {
int get ();
void set (int value);
}
public function get Y2 () : int
public function set Y2 (value : int)
Property Value
Type: System.Int32
An Integer that represents the Y (vertical) coordinate of the ending point of the line.
Remarks
The coordinate is relative to the container of the LineShape control and is expressed in pixels.
You can also change the ending coordinates by setting the EndPoint property.
Examples
The following example demonstrates how to change the direction of a diagonal line by changing the X1, Y1, X2, and Y2 properties.
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 Security
- Full trust for the immediate caller. This member cannot be used by partially trusted code. For more information, see Using Libraries from Partially Trusted Code.
See Also
Reference
Microsoft.VisualBasic.PowerPacks Namespace
Other Resources
How to: Draw Shapes with the OvalShape and RectangleShape Controls (Visual Studio)
How to: Draw Lines with the LineShape Control (Visual Studio)