Reassigning a control's parent
-
I am developing a custom component in the form of a specialized panel. To this panel i have added another panel. When a user adds a control to the specialized panel i want it to capture this action and place the new control in the panel i have already in my control. I have therefore, overrident the OnControlAdded Sub and added the following:
MyBase.OnControlAdded(e) For Each c As Control In Me.Controls If c.Tag = "BottomPanel" Then c.controls.add(e.control) End If Next
However when i tell it to do this i get an error from visual studio itself saying, "'child' is not a child of this parent."
Please check out my articles: The ANZAC's articles
-
I am developing a custom component in the form of a specialized panel. To this panel i have added another panel. When a user adds a control to the specialized panel i want it to capture this action and place the new control in the panel i have already in my control. I have therefore, overrident the OnControlAdded Sub and added the following:
MyBase.OnControlAdded(e) For Each c As Control In Me.Controls If c.Tag = "BottomPanel" Then c.controls.add(e.control) End If Next
However when i tell it to do this i get an error from visual studio itself saying, "'child' is not a child of this parent."
Please check out my articles: The ANZAC's articles
Reckon you need to use a for loop ( not for each ) so you can remove items from the existing controls collection, on the basis that I doubt a control can exist in two at the same time.
Christian Graus - Microsoft MVP - C++ "also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )