Export (0) Print
Expand All

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)

public IContainerControl GetContainerControl()

Return Value

Type: System.Windows.Forms.IContainerControl
An IContainerControl that represents the parent of the control.

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.

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 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;

© 2014 Microsoft