CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5
  1. #1
    Join Date
    Nov 2011
    Posts
    63

    UserControl won't fit on Form

    Hello,

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

    Name:  usercontrol not fitting.jpg
Views: 372
Size:  21.6 KB

    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.

  2. #2
    Join Date
    Oct 2004
    Location
    Rocket City
    Posts
    220

    Re: UserControl won't fit on Form

    Have you tried Dock: DockStyle.Fill yet?

  3. #3
    Join Date
    Nov 2011
    Posts
    63

    Re: UserControl won't fit on Form

    Quote Originally Posted by zips View Post
    Have you tried Dock: DockStyle.Fill yet?
    That doesn't seem to work.

  4. #4
    Arjay's Avatar
    Arjay is offline Moderator / EX MS MVP Power Poster
    Join Date
    Aug 2004
    Posts
    13,490

    Re: UserControl won't fit on Form

    Open the xxx.designer.cs file and make sure the user control has the proper parent control set. It's parent should be the panel.

  5. #5
    Join Date
    Nov 2011
    Posts
    63

    Re: UserControl won't fit on Form

    I seem to have solved the problem by docking my ListBox to "top". Thanks for everyone's help.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured