Hello,
I have a form that has hit its max for controls. I have created a UserControl to add more to the form. I can re-size the UserControl but the controls on the UserControl are not resizing. I have the Sheridan ActiveResizer tool on the form that works with all of the controls on the form. I have tried adding this tool to the UserControl but when I set the Height and Width of the UserControl the Resizer does not resize the rest of the controls. Any help with this is greatly appreciated.

Thanks

Have you thought about breaking up the form into a number of smaller forms and containing them all in a parent form.

I can re-size the UserControl but the controls on the UserControl are not resizing.

The User Control has its own resize event. You could write could in that event to resize the controls inside that control. That would be the most logical place to try.

Private Sub UserControl_Resize()
    Dim ctl As Control
    For Each ctl In Me
         ' Write code to deal with the different controls inside the UserControl.
    Next
End Sub

Edited 4 Years Ago by hkdani: clarification

After messing with this, apparently, you can't use the Me keyword inside of a user control. In other words, the user control cannot reference itself in code as in a normal form--as far as I can tell.

You can, however, just use the key words Width and Height. So in a user control Me.Width should be replaced with Width and Me.Height should be replaced with Height to obtain the current Height and Width of the user control.

Looks like the only problem with this workaround is that you can't take advantage of the Me keyword and you would have to know in advance which controls are inside the user control.

If someone knows how to reference a user control inside of itself, that would make it simpler. But that apparently is the root problem that you're mentioning in your first post or the reason you cannot use the resizer inside the user control.

Private Sub UserControl_Resize()
    Dim ctl As Control
    For Each ctl In Me
         ' Write code to deal with the different controls inside the UserControl.
    Next
    ' Previous code will not work
    ' Write code to deal with known controls on the user control.
    ' Not very flexible. But that's the only solution that I could come up with at this time.
End Sub
This article has been dead for over six months. Start a new discussion instead.