Compartir a través de


Shape.FindForm Method

Retrieves the form that a line or shape control is on.

Namespace:  Microsoft.VisualBasic.PowerPacks
Assembly:  Microsoft.VisualBasic.PowerPacks.Vs (in Microsoft.VisualBasic.PowerPacks.Vs.dll)

Syntax

'Declaración
Public Function FindForm As Form
public Form FindForm()
public:
Form^ FindForm()
member FindForm : unit -> Form 
public function FindForm() : Form

Return Value

Type: System.Windows.Forms.Form
The Form that the control is on.

Remarks

The control's Parent property value will not be the same as the Form returned by the FindForm method. The parent of a line or shape control is always a ShapeContainer, and the ShapeContainer could be contained in a container control. Consider an example in which a LineShape control is contained in a GroupBox control and the GroupBox is on a Form. In this example, the control's Parent is a ShapeContainer, the ShapeContainer object's Parent is a GroupBox, and the GroupBox control's Parent is the Form.

Examples

The following example demonstrates how to use the FindForm method to determine which form contains a LineShape control.

Private Sub GetTheForm()
    Dim myForm As Form = LineShape1.FindForm()
    ' Set the text and color of the form that contains the LineShape.
    myForm.Text = "This form contains a line"
    myForm.BackColor = Color.Red
End Sub
private void GetTheForm()
{
    Form myForm = lineShape1.FindForm();
    // Set the text and color of the form that contains the LineShape.
    myForm.Text = "This form contains a line";
    myForm.BackColor = Color.Red;
}

.NET Framework Security

See Also

Reference

Shape Class

Microsoft.VisualBasic.PowerPacks Namespace

Other Resources

How to: Draw Lines with the LineShape Control (Visual Studio)

How to: Draw Shapes with the OvalShape and RectangleShape Controls (Visual Studio)

Introduction to the Line and Shape Controls (Visual Studio)