I have created 40 or so OvalShapes from MS power packs and when the user clicks them they send an ID to separate function that is supposed to change the color of the clicked oval. Unfortunately the Controls method seems to not work.
Controls.Item(Dummy).fillcolor = Color.Red gives me an error saying "FillColor is not a member of 'System.Windows.Forms.Control'" where Dummy is the string containing the name of the control.
I'm fairly new to VB.NET so I'm not sure if there's another way to reference things on the form via a string besides using Controls. Google hasn't really helped on this matter too much, all I found was a way to search through all shapes using the CType on all controls that match the oval type which isn't helpful when I just want to change one control...
Edit: I am looking to be able to do something like the following:
For i = 1 to 40
OvalName = "Oval" & i
if Ovali = then do something
Next
I am not sure how you are adding your OvalShapes or what type of container you are using. In order to add them to a Windows Form Control you will need to use the shapeContainer as mentioned by Slaks. In this example I am creating a shapeContainer and adding it to the Form, then I am using the shapeContainers.Shapes.Add Method to add the oval to the ShapeCollection Class. I also am attaching an eventhandler to the Click Event of the Ovals so that I can access the calling Shape to change its fill color through the sender object of the EventHandler. See if this will work for you.
Edit per OP's clarification
When you create your ovals add
oval.Name = "oval" & indexthis will add the name property that will enable the following code to work.You can iterate through the Shapes Collection like this(this is based off of my above example):
or you can search for the exact Oval that you are looking for by using the
ShapeContainer.Shapes.IndexOfKeyMethod