ShapeContainer Class

 

Provides a container for LineShape, OvalShape, RectangleShape controls, and for any other control that derives from Shape.

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

Inheritance Hierarchy

System.Object
  System.MarshalByRefObject
    System.ComponentModel.Component
      System.Windows.Forms.Control
        System.Windows.Forms.ScrollableControl
          System.Windows.Forms.ContainerControl
            System.Windows.Forms.UserControl
              Microsoft.VisualBasic.PowerPacks.ShapeContainer

Syntax

[BrowsableAttribute(false)]
public sealed class ShapeContainer : UserControl
[BrowsableAttribute(false)]
public ref class ShapeContainer sealed : UserControl
[<Sealed>]
[<BrowsableAttribute(false)>]
type ShapeContainer = 
    class
        inherit UserControl
    end
<BrowsableAttribute(False)>
Public NotInheritable Class ShapeContainer
    Inherits UserControl

Constructors

Name Description
System_CAPS_pubmethod ShapeContainer()

Initializes a new instance of the ShapeContainer class.

Properties

Name Description
System_CAPS_pubproperty AccessibilityObject

(Inherited from Control.)

System_CAPS_pubproperty AccessibleDefaultActionDescription

(Inherited from Control.)

System_CAPS_pubproperty AccessibleDescription

(Inherited from Control.)

System_CAPS_pubproperty AccessibleName

(Inherited from Control.)

System_CAPS_pubproperty AccessibleRole

Gets or sets the accessible role of the ShapeContainer.

System_CAPS_pubproperty ActiveControl

(Inherited from ContainerControl.)

System_CAPS_pubproperty AllowDrop

(Inherited from Control.)

System_CAPS_pubproperty Anchor

(Inherited from Control.)

System_CAPS_pubproperty AutoScaleDimensions

(Inherited from ContainerControl.)

System_CAPS_pubproperty AutoScaleMode

(Inherited from ContainerControl.)

System_CAPS_pubproperty AutoScroll

(Inherited from ScrollableControl.)

System_CAPS_pubproperty AutoScrollMargin

(Inherited from ScrollableControl.)

System_CAPS_pubproperty AutoScrollMinSize

(Inherited from ScrollableControl.)

System_CAPS_pubproperty AutoScrollOffset

(Inherited from Control.)

System_CAPS_pubproperty AutoScrollPosition

(Inherited from ScrollableControl.)

System_CAPS_pubproperty AutoSize

(Inherited from UserControl.)

System_CAPS_pubproperty AutoSizeMode

(Inherited from UserControl.)

System_CAPS_pubproperty AutoValidate

(Inherited from UserControl.)

System_CAPS_pubproperty BackColor

(Inherited from Control.)

System_CAPS_pubproperty BackgroundImage

(Inherited from Control.)

System_CAPS_pubproperty BackgroundImageLayout

(Inherited from Control.)

System_CAPS_pubproperty BindingContext

(Inherited from ContainerControl.)

System_CAPS_pubproperty BorderStyle

(Inherited from UserControl.)

System_CAPS_pubproperty Bottom

(Inherited from Control.)

System_CAPS_pubproperty Bounds

(Inherited from Control.)

System_CAPS_pubproperty CanFocus

(Inherited from Control.)

System_CAPS_pubproperty CanSelect

(Inherited from Control.)

System_CAPS_pubproperty Capture

(Inherited from Control.)

System_CAPS_pubproperty CausesValidation

(Inherited from Control.)

System_CAPS_pubproperty ClientRectangle

(Inherited from Control.)

System_CAPS_pubproperty ClientSize

(Inherited from Control.)

System_CAPS_pubproperty CompanyName

(Inherited from Control.)

System_CAPS_pubproperty Container

(Inherited from Component.)

System_CAPS_pubproperty ContainsFocus

(Inherited from Control.)

System_CAPS_pubproperty ContextMenu

(Inherited from Control.)

System_CAPS_pubproperty ContextMenuStrip

(Inherited from Control.)

System_CAPS_pubproperty Controls

(Inherited from Control.)

System_CAPS_pubproperty Created

(Inherited from Control.)

System_CAPS_pubproperty CurrentAutoScaleDimensions

(Inherited from ContainerControl.)

System_CAPS_pubproperty Cursor

Gets or sets the cursor that is displayed when the mouse pointer is over a ShapeContainer.(Overrides Control.Cursor.)

System_CAPS_pubproperty DataBindings

(Inherited from Control.)

System_CAPS_pubproperty DisplayRectangle

(Inherited from ScrollableControl.)

System_CAPS_pubproperty Disposing

(Inherited from Control.)

System_CAPS_pubproperty Dock

Gets or sets which control borders are docked to the parent control and determines how a control is resized when its parent is resized.(Overrides Control.Dock.)

System_CAPS_pubproperty Enabled

(Inherited from Control.)

System_CAPS_pubproperty Focused

(Inherited from Control.)

System_CAPS_pubproperty Font

(Inherited from Control.)

System_CAPS_pubproperty ForeColor

(Inherited from Control.)

System_CAPS_pubproperty Handle

(Inherited from Control.)

System_CAPS_pubproperty HasChildren

(Inherited from Control.)

System_CAPS_pubproperty Height

(Inherited from Control.)

System_CAPS_pubproperty HorizontalScroll

(Inherited from ScrollableControl.)

System_CAPS_pubproperty ImeMode

(Inherited from Control.)

System_CAPS_pubproperty InvokeRequired

(Inherited from Control.)

System_CAPS_pubproperty IsAccessible

(Inherited from Control.)

System_CAPS_pubproperty IsDisposed

(Inherited from Control.)

System_CAPS_pubproperty IsHandleCreated

(Inherited from Control.)

System_CAPS_pubproperty IsMirrored

(Inherited from Control.)

System_CAPS_pubproperty LayoutEngine

(Inherited from Control.)

System_CAPS_pubproperty Left

(Inherited from Control.)

System_CAPS_pubproperty Location

(Inherited from Control.)

System_CAPS_pubproperty Margin

(Inherited from Control.)

System_CAPS_pubproperty MaximumSize

(Inherited from Control.)

System_CAPS_pubproperty MinimumSize

(Inherited from Control.)

System_CAPS_pubproperty Name

(Inherited from Control.)

System_CAPS_pubproperty Padding

(Inherited from Control.)

System_CAPS_pubproperty Parent

(Inherited from Control.)

System_CAPS_pubproperty ParentForm

(Inherited from ContainerControl.)

System_CAPS_pubproperty PreferredSize

(Inherited from Control.)

System_CAPS_pubproperty ProductName

(Inherited from Control.)

System_CAPS_pubproperty ProductVersion

(Inherited from Control.)

System_CAPS_pubproperty RecreatingHandle

(Inherited from Control.)

System_CAPS_pubproperty Region

(Inherited from Control.)

System_CAPS_protproperty RenderRightToLeft

(Inherited from Control.)

System_CAPS_pubproperty Right

(Inherited from Control.)

System_CAPS_pubproperty RightToLeft

(Inherited from Control.)

System_CAPS_pubproperty Shapes

Gets the collection of shapes that are contained in the ShapeContainer.

System_CAPS_protproperty ShowFocusCues

(Inherited from Control.)

System_CAPS_protproperty ShowKeyboardCues

(Inherited from Control.)

System_CAPS_pubproperty Site

(Inherited from Control.)

System_CAPS_pubproperty Size

(Inherited from Control.)

System_CAPS_pubproperty TabIndex

(Inherited from Control.)

System_CAPS_pubproperty TabStop

(Inherited from Control.)

System_CAPS_pubproperty Tag

(Inherited from Control.)

System_CAPS_pubproperty Text

(Inherited from Control.)

System_CAPS_pubproperty Top

(Inherited from Control.)

System_CAPS_pubproperty TopLevelControl

(Inherited from Control.)

System_CAPS_pubproperty UseWaitCursor

(Inherited from Control.)

System_CAPS_pubproperty VerticalScroll

(Inherited from ScrollableControl.)

System_CAPS_pubproperty Visible

(Inherited from Control.)

System_CAPS_pubproperty Width

(Inherited from Control.)

Methods

Name Description
System_CAPS_protmethod AccessibilityNotifyClients(AccessibleEvents, Int32)

(Inherited from Control.)

System_CAPS_pubmethod BeginInvoke(Delegate)

(Inherited from Control.)

System_CAPS_pubmethod BeginInvoke(Delegate, Object[])

(Inherited from Control.)

System_CAPS_pubmethod BringToFront()

(Inherited from Control.)

System_CAPS_pubmethod Contains(Control)

(Inherited from Control.)

System_CAPS_pubmethod CreateControl()

(Inherited from Control.)

System_CAPS_pubmethod CreateGraphics()

(Inherited from Control.)

System_CAPS_pubmethod CreateObjRef(Type)

(Inherited from MarshalByRefObject.)

System_CAPS_pubmethod Dispose()

(Inherited from Component.)

System_CAPS_pubmethod DoDragDrop(Object, DragDropEffects)

(Inherited from Control.)

System_CAPS_pubmethod DrawToBitmap(Bitmap, Rectangle)

(Inherited from Control.)

System_CAPS_pubmethod EndInvoke(IAsyncResult)

(Inherited from Control.)

System_CAPS_pubmethod Equals(Object)

(Inherited from Object.)

System_CAPS_pubmethod FindForm()

(Inherited from Control.)

System_CAPS_pubmethod Focus()

(Inherited from Control.)

System_CAPS_pubmethod GetChildAtPoint(Point)

Gets the shape that is located at the specified coordinates.

System_CAPS_pubmethod GetChildAtPoint(Point, GetChildAtPointSkip)

(Inherited from Control.)

System_CAPS_pubmethod GetContainerControl()

(Inherited from Control.)

System_CAPS_pubmethod GetHashCode()

(Inherited from Object.)

System_CAPS_pubmethod GetLifetimeService()

(Inherited from MarshalByRefObject.)

System_CAPS_pubmethod GetNextControl(Control, Boolean)

(Inherited from Control.)

System_CAPS_pubmethod GetNextShape(Shape, Boolean)

Retrieves the next or previous shape in the order of the ShapeCollection.

System_CAPS_pubmethod GetPreferredSize(Size)

(Inherited from Control.)

System_CAPS_pubmethod GetType()

(Inherited from Object.)

System_CAPS_pubmethod Hide()

(Inherited from Control.)

System_CAPS_pubmethod InitializeLifetimeService()

(Inherited from MarshalByRefObject.)

System_CAPS_pubmethod Invalidate()

(Inherited from Control.)

System_CAPS_pubmethod Invalidate(Boolean)

(Inherited from Control.)

System_CAPS_pubmethod Invalidate(Rectangle)

(Inherited from Control.)

System_CAPS_pubmethod Invalidate(Rectangle, Boolean)

(Inherited from Control.)

System_CAPS_pubmethod Invalidate(Region)

(Inherited from Control.)

System_CAPS_pubmethod Invalidate(Region, Boolean)

(Inherited from Control.)

System_CAPS_pubmethod Invoke(Delegate)

(Inherited from Control.)

System_CAPS_pubmethod Invoke(Delegate, Object[])

(Inherited from Control.)

System_CAPS_pubmethod PerformAutoScale()

(Inherited from ContainerControl.)

System_CAPS_pubmethod PerformLayout()

(Inherited from Control.)

System_CAPS_pubmethod PerformLayout(Control, String)

(Inherited from Control.)

System_CAPS_pubmethod PointToClient(Point)

(Inherited from Control.)

System_CAPS_pubmethod PointToScreen(Point)

(Inherited from Control.)

System_CAPS_pubmethod PreProcessControlMessage(Message)

(Inherited from Control.)

System_CAPS_pubmethod PreProcessMessage(Message)

(Inherited from Control.)

System_CAPS_protmethod ProcessKeyMessage(Message)

(Inherited from Control.)

System_CAPS_protmethod ProcessMnemonic(Char)

(Inherited from ContainerControl.)

System_CAPS_pubmethod RectangleToClient(Rectangle)

(Inherited from Control.)

System_CAPS_pubmethod RectangleToScreen(Rectangle)

(Inherited from Control.)

System_CAPS_pubmethod Refresh()

(Inherited from Control.)

System_CAPS_pubmethod ResetText()

(Inherited from Control.)

System_CAPS_pubmethod ResumeLayout()

(Inherited from Control.)

System_CAPS_pubmethod ResumeLayout(Boolean)

(Inherited from Control.)

System_CAPS_protmethod RtlTranslateContent(ContentAlignment)

(Inherited from Control.)

System_CAPS_pubmethod Scale(SizeF)

(Inherited from Control.)

System_CAPS_pubmethod ScrollControlIntoView(Control)

(Inherited from ScrollableControl.)

System_CAPS_pubmethod Select()

(Inherited from Control.)

System_CAPS_pubmethod SelectNextControl(Control, Boolean, Boolean, Boolean, Boolean)

(Inherited from Control.)

System_CAPS_pubmethod SelectNextShape(Shape, Boolean, Boolean)

Selects the next or previous shape in the order of the ShapeCollection.

System_CAPS_pubmethod SendToBack()

(Inherited from Control.)

System_CAPS_pubmethod SetAutoScrollMargin(Int32, Int32)

(Inherited from ScrollableControl.)

System_CAPS_pubmethod SetBounds(Int32, Int32, Int32, Int32)

(Inherited from Control.)

System_CAPS_pubmethod SetBounds(Int32, Int32, Int32, Int32, BoundsSpecified)

(Inherited from Control.)

System_CAPS_pubmethod Show()

(Inherited from Control.)

System_CAPS_pubmethod SuspendLayout()

(Inherited from Control.)

System_CAPS_pubmethod ToString()

(Inherited from Component.)

System_CAPS_pubmethod Update()

(Inherited from Control.)

System_CAPS_protmethod UpdateBounds()

(Inherited from Control.)

System_CAPS_pubmethod Validate()

(Inherited from ContainerControl.)

System_CAPS_pubmethod Validate(Boolean)

(Inherited from ContainerControl.)

System_CAPS_pubmethod ValidateChildren()

(Inherited from UserControl.)

System_CAPS_pubmethod ValidateChildren(ValidationConstraints)

(Inherited from UserControl.)

Events

Name Description
System_CAPS_pubevent AutoSizeChanged

(Inherited from UserControl.)

System_CAPS_pubevent AutoValidateChanged

(Inherited from UserControl.)

System_CAPS_pubevent BackColorChanged

(Inherited from Control.)

System_CAPS_pubevent BackgroundImageChanged

(Inherited from Control.)

System_CAPS_pubevent BackgroundImageLayoutChanged

(Inherited from Control.)

System_CAPS_pubevent BindingContextChanged

(Inherited from Control.)

System_CAPS_pubevent CausesValidationChanged

(Inherited from Control.)

System_CAPS_pubevent ChangeUICues

(Inherited from Control.)

System_CAPS_pubevent Click

(Inherited from Control.)

System_CAPS_pubevent ClientSizeChanged

(Inherited from Control.)

System_CAPS_pubevent ContextMenuChanged

(Inherited from Control.)

System_CAPS_pubevent ContextMenuStripChanged

(Inherited from Control.)

System_CAPS_pubevent ControlAdded

(Inherited from Control.)

System_CAPS_pubevent ControlRemoved

(Inherited from Control.)

System_CAPS_pubevent CursorChanged

(Inherited from Control.)

System_CAPS_pubevent Disposed

(Inherited from Component.)

System_CAPS_pubevent DockChanged

(Inherited from Control.)

System_CAPS_pubevent DoubleClick

(Inherited from Control.)

System_CAPS_pubevent DragDrop

(Inherited from Control.)

System_CAPS_pubevent DragEnter

(Inherited from Control.)

System_CAPS_pubevent DragLeave

(Inherited from Control.)

System_CAPS_pubevent DragOver

(Inherited from Control.)

System_CAPS_pubevent EnabledChanged

(Inherited from Control.)

System_CAPS_pubevent Enter

(Inherited from Control.)

System_CAPS_pubevent FontChanged

(Inherited from Control.)

System_CAPS_pubevent ForeColorChanged

(Inherited from Control.)

System_CAPS_pubevent GiveFeedback

(Inherited from Control.)

System_CAPS_pubevent GotFocus

(Inherited from Control.)

System_CAPS_pubevent HandleCreated

(Inherited from Control.)

System_CAPS_pubevent HandleDestroyed

(Inherited from Control.)

System_CAPS_pubevent HelpRequested

(Inherited from Control.)

System_CAPS_pubevent ImeModeChanged

(Inherited from Control.)

System_CAPS_pubevent Invalidated

(Inherited from Control.)

System_CAPS_pubevent KeyDown

(Inherited from Control.)

System_CAPS_pubevent KeyPress

(Inherited from Control.)

System_CAPS_pubevent KeyUp

(Inherited from Control.)

System_CAPS_pubevent Layout

(Inherited from Control.)

System_CAPS_pubevent Leave

(Inherited from Control.)

System_CAPS_pubevent Load

(Inherited from UserControl.)

System_CAPS_pubevent LocationChanged

(Inherited from Control.)

System_CAPS_pubevent LostFocus

(Inherited from Control.)

System_CAPS_pubevent MarginChanged

(Inherited from Control.)

System_CAPS_pubevent MouseCaptureChanged

(Inherited from Control.)

System_CAPS_pubevent MouseClick

(Inherited from Control.)

System_CAPS_pubevent MouseDoubleClick

(Inherited from Control.)

System_CAPS_pubevent MouseDown

(Inherited from Control.)

System_CAPS_pubevent MouseEnter

(Inherited from Control.)

System_CAPS_pubevent MouseHover

(Inherited from Control.)

System_CAPS_pubevent MouseLeave

(Inherited from Control.)

System_CAPS_pubevent MouseMove

(Inherited from Control.)

System_CAPS_pubevent MouseUp

(Inherited from Control.)

System_CAPS_pubevent MouseWheel

(Inherited from Control.)

System_CAPS_pubevent Move

(Inherited from Control.)

System_CAPS_pubevent PaddingChanged

(Inherited from Control.)

System_CAPS_pubevent Paint

(Inherited from Control.)

System_CAPS_pubevent ParentChanged

(Inherited from Control.)

System_CAPS_pubevent PreviewKeyDown

(Inherited from Control.)

System_CAPS_pubevent QueryAccessibilityHelp

(Inherited from Control.)

System_CAPS_pubevent QueryContinueDrag

(Inherited from Control.)

System_CAPS_pubevent RegionChanged

(Inherited from Control.)

System_CAPS_pubevent Resize

(Inherited from Control.)

System_CAPS_pubevent RightToLeftChanged

(Inherited from Control.)

System_CAPS_pubevent Scroll

(Inherited from ScrollableControl.)

System_CAPS_pubevent SizeChanged

(Inherited from Control.)

System_CAPS_pubevent StyleChanged

(Inherited from Control.)

System_CAPS_pubevent SystemColorsChanged

(Inherited from Control.)

System_CAPS_pubevent TabIndexChanged

(Inherited from Control.)

System_CAPS_pubevent TabStopChanged

(Inherited from Control.)

System_CAPS_pubevent TextChanged

(Inherited from Control.)

System_CAPS_pubevent Validated

(Inherited from Control.)

System_CAPS_pubevent Validating

(Inherited from Control.)

System_CAPS_pubevent VisibleChanged

(Inherited from Control.)

Explicit Interface Implementations

Name Description
System_CAPS_pubinterfaceSystem_CAPS_privmethod IContainerControl.ActivateControl(Control)

(Inherited from ContainerControl.)

System_CAPS_pubinterfaceSystem_CAPS_privmethod IDropTarget.OnDragDrop(DragEventArgs)

(Inherited from Control.)

System_CAPS_pubinterfaceSystem_CAPS_privmethod IDropTarget.OnDragEnter(DragEventArgs)

(Inherited from Control.)

System_CAPS_pubinterfaceSystem_CAPS_privmethod IDropTarget.OnDragLeave(EventArgs)

(Inherited from Control.)

System_CAPS_pubinterfaceSystem_CAPS_privmethod IDropTarget.OnDragOver(DragEventArgs)

(Inherited from Control.)

Remarks

A LineShape, OvalShape, or RectangleShape control can be contained only in a ShapeContainer object, which acts as a canvas for line and shape controls.

When you add a line or shape to a form or container at design time, a ShapeContainer is automatically created if one does not already exist. The Parent property of the line or shape is set to that ShapeContainer. The Parent property of the ShapeContainer is set to the form or container control to which the line or shape was added.

When you create a line or shape at run time by using the New method, the control's Parent property must be set to a ShapeContainer. If a ShapeContainer already exists for the form or container, you should set the Parent property to that ShapeContainer. If no ShapeContainer exists, you can create a ShapeContainer by using the New method and set its Parent property to the form or container.

Note

Be careful that you do not create more than one ShapeContainer for each form or container; doing this may introduce unexpected behavior. If you add a design-time line or shape control to a form or container after you write code to create one programmatically, you should modify that code to use the ShapeContainer created by the designer.

Examples

The following example checks for an existing ShapeContainer and sets the Parent property of an OvalShape control created at run time by using the New method.

private void form1_Load(System.Object sender, System.EventArgs e)
{
    OvalShape NewOval = new OvalShape();
    int i;
    bool found = false;
    // Loop through the Controls collection.
    for (i = 0; i < this.Controls.Count; i++)
    {
        // If a ShapeContainer is found, make it the parent.
        if (this.Controls[i] is ShapeContainer)
        {
            NewOval.Parent = ((ShapeContainer)this.Controls[i]);
            found = true;
            break;
        }
    }
    // If no ShapeContainer is found, create one and set the parents.
    if (found == false)
    {
        ShapeContainer sc = new ShapeContainer();
        sc.Parent = this;
        NewOval.Parent = sc;
    }
    NewOval.Size = new Size(200, 300);
}
Private Sub Form1_Load() Handles MyBase.Load
    Dim NewOval As New OvalShape
    Dim i As Integer
    Dim found As Boolean
    ' Loop through the Controls collection.
    For i = 0 To Me.Controls.Count - 1
        ' If a ShapeContainer is found, make it the parent.
        If TypeOf Controls.Item(i) Is ShapeContainer Then
            NewOval.Parent = Controls.Item(i)
            found = True
            Exit For
        End If
    Next
    ' If no ShapeContainer is found, create one and set the parents.
    If found = False Then
        Dim sc As New ShapeContainer
        sc.Parent = Me
        NewOval.Parent = sc
    End If
    NewOval.Size = New Size(200, 300)
End Sub

Thread Safety

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

See Also

Microsoft.VisualBasic.PowerPacks Namespace
Introduction to the Line and Shape Controls (Visual Studio)
How to: Draw Lines with the LineShape Control (Visual Studio)
How to: Draw Shapes with the OvalShape and RectangleShape Controls (Visual Studio)

Return to top