Shape.GetContainerControl Method
Returns the next ContainerControl up in a line or shape control's chain of parent controls.
Namespace: Microsoft.VisualBasic.PowerPacks
Assembly: Microsoft.VisualBasic.PowerPacks.Vs (in Microsoft.VisualBasic.PowerPacks.Vs.dll)
Syntax
'Declaration
Public Function GetContainerControl As IContainerControl
'Usage
Dim instance As Shape
Dim returnValue As IContainerControl
returnValue = instance.GetContainerControl()
public IContainerControl GetContainerControl()
public:
IContainerControl^ GetContainerControl()
public function GetContainerControl() : IContainerControl
Return Value
Type: System.Windows.Forms.IContainerControl
An IContainerControl that represents the parent of the control.
Remarks
For LineShape, OvalShape, and RectangleShape controls, the Parent property always returns a ShapeContainer object. The GetContainerControl method can be used to obtain the parent of the ShapeContainer object.
Examples
The following example sets the BackColor of the Panel control that contains an OvalShape control. This example requires that you have a Panel control named Panel1 and an OvalShape control named OvalShape1 on a form.
Private Sub OvalShape1_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles OvalShape1.Click
' Declare a Control.
Dim ctl As Control
' Find the container for the OvalShape.
ctl = OvalShape1.GetContainerControl.ActiveControl.Parent
' Change the color of the container.
ctl.BackColor = Color.Blue
End Sub
private void ovalShape1_Click(System.Object sender, System.EventArgs e)
{
// Declare a Control.
Control ctl;
// Find the container for the OvalShape.
ctl = ((Control)ovalShape1.GetContainerControl());
// Change the color of the container.
ctl.BackColor = Color.Blue;
}
.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 Lines with the LineShape Control (Visual Studio)
How to: Draw Shapes with the OvalShape and RectangleShape Controls (Visual Studio)