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
public Form FindForm()
public:
Form^ FindForm()
member FindForm : unit -> Form
Public Function FindForm As 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 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;
}
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
See Also
Shape Class
Microsoft.VisualBasic.PowerPacks Namespace
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)
Return to top