Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

UserControl not fitting onto Form

Status
Not open for further replies.

gib99

Programmer
Mar 23, 2012
51
CA
Hello,

I'm having trouble getting my UserControl to fit snuggly in my panel. Here's a screen shot of what it looks like:

usercontrol_not_fitting.jpg


The UserControl is in red and the panel I'm trying to fit it onto is in grey (the white is a ListBox in my UserControl). As you can see,

it's going off the right edge of the Form.

I have these settings for both the panel and the UserControl:

AutoSize: true
AutoSizeMode: GrowAndShrink
Anchor: AnchorStyle.Left | AnchorStyle.Top | AnchorStyle.Right
Dock: DockStyle.Top

But for some reason, either the panel or the UserControl doesn't want to shrink down to the appropriate size.

Any help would be very much appreciated.
 
You haven't shown the code that you use to place your control in the panel. Try adding your control to the Controls collection of the Panel and if appropriate set a suitable DockingStyle
 
Thanks softhemc,

Setting dockstyle to top worked.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top