Shape.FindForm 方法

检索 line 或 shape 控件的窗体。

命名空间:  Microsoft.VisualBasic.PowerPacks
程序集:  Microsoft.VisualBasic.PowerPacks.Vs(在 Microsoft.VisualBasic.PowerPacks.Vs.dll 中)

语法

声明
Public Function FindForm As Form
public Form FindForm()
public:
Form^ FindForm()
member FindForm : unit -> Form 
public function FindForm() : Form

返回值

类型:System.Windows.Forms.Form
控件所在的 Form

备注

控件的 Parent 属性值不是 Form 用 FindForm 方法返回相同。line 或 shape 控件的父始终是 ShapeContainer,并且, ShapeContainer 可以在容器控件中。考虑 LineShape 控件在 GroupBox 控件包含,并且 GroupBoxForm的一个示例。在此示例中,控件的 ParentShapeContainerShapeContainer 对象的 ParentGroupBox,并且, GroupBox 控件的 ParentForm

示例

下面的示例演示如何使用 FindForm 方法确定哪种形式包含一个 LineShape 控件。

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 安全性

请参见

参考

Shape 类

Microsoft.VisualBasic.PowerPacks 命名空间

其他资源

如何:使用 LineShape 控件绘制直线 (Visual Studio)

如何:使用 OvalShape 和 RectangleShape 控件绘制形状 (Visual Studio)

Line 和 Shape 控件简介 (Visual Studio)