I am trying to make a usercontrol which is a 3D line that sits above the “Ok” and “Cancel” button as seen in the Thunderbird windows sometimes:
http://s11.postimage.org/gh45ux9wj/thunderbird1.png
I do not want to have to set the anchor property manually each time I put the usercontrol on a form, that is why I wanted to make it so within the usercontrol that it docks automatically to the parent (Left=0, Width=Parent.Width).
However, I do not really manage to do so.
My attemps were manyfold, so I am not sure what I should post here.
My assumption was that I should use
Private Sub UserControl1_ParentChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.ParentChanged
Me.SetBounds(0, Me.Top, Me.Parent.Width, 0, BoundsSpecified.X Or BoundsSpecified.Y Or BoundsSpecified.Width)
End Sub
But that does not work at all.
You need to add an event handler to the parent’s
Resizeevent so that you will be notified every time the parent’s size changes. For instance, something like this will work: