Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Change control's parent at runtime VB.NET

I'm making a custom control that can be dragged around and it is semi transparent. I need it so that while it is moving (the mousemove event) that if it intersects a control that its parent becomes that control. I tried to have it iterate through all the controls and if control.bounds.intersectswith me.clientrectangle then me.parent = control type thing, but it did not work. Any help would be appreciated thanks.

like image 738
jmasterx Avatar asked Jun 09 '26 12:06

jmasterx


1 Answers

Since you have references to both the original parent and the new parent, do the following:

OriginalParent.controls.remove(YourControl)

NewParent.controls.add(YourControl)
like image 89
Einar Guðsteinsson Avatar answered Jun 12 '26 12:06

Einar Guðsteinsson



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!