Hi,
I want to make a UserControl which holds and moves other controls within itself.
I worry that the Controls collection can be used to destroy all the internal logic of the UserControl.
Remembering that the .Net Framework TableLayoutPanel locates its own Controls, I created a 30x30 TableLayoutPanelm each cell containing a square Label with its BorderStyle set to FixedSingle.
I then added a Button to my form with the following click function:
For Each controlIn As Control In Me.TableLayoutPanel1.Controls
controlIn.Location = New Point(controlIn.Location.X + 10, controlIn.Location.Y + 10)
Next
This results in a quite visible ripple effect across the labels as each control is in turn moved and moved back, before the next control is moved in its turn.
From this, I deduce that a TableLayoutPanel contains something along the lines of a Dictionary(Of Control, Point) for each of its controls, and handles the LocationChanged event of its controls with something along the lines of:
Private Sub myControlMovedHandler(sender as Object, e as System.EventArgs)
sender.Location = me.myControlDictionary(sender)
End Sub
Which would account for each control moving in turn and then moving back to its original location.
My question is basically: "Does anyone have any better ideas?"