Changing multiple ovalshape size during runtime

Answered Changing multiple ovalshape size during runtime

  • Tuesday, March 13, 2012 6:34 AM
     
     

    Hi, 

    I am new to VB.2010, I am using the PowerPack and trying to change multiple ovalshape size, I have used the following code for changing multiple labels, 

                For Count As Integer = 1 To 100
                    Me.Controls("Label" & Count).Text= "Hello World"
                Next Count

    If I do the same for OvalShape, assume I have OvalShape1, OvalShape2.... OvalShape100

                For Count As Integer = 1 To 100
                    Me.Controls("OvalShape" & Count).Size = New System.Drawing.Size(20, 20)
                Next Count

    The above throws error when executed. 

    Can anyone PLEASE guide/advice me what I am doing wrong. 

    Thanks In Advance

    M.Pathma

All Replies

  • Tuesday, March 13, 2012 7:55 AM
     
     Answered Has Code

    You can't do that with shapes.  They are not controls that are part of the controls collection of the form - they are shapes that are part of the shapes collection of the shapecontainer.  You can't reference them by name.  Use code like this:

            For Count As Integer = 0 To 99
                Me.ShapeContainer1.Shapes(Count).Size = New System.Drawing.Size(20, 20)
            Next Count
    You might be trying to use shapes for a more sophisticated level of functionality than they were designed to support.