Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7898199
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T08:22:09+00:00 2026-06-03T08:22:09+00:00

When a control with Dock = DockStyle.Fill is a child of another control with

  • 0

When a control with Dock = DockStyle.Fill is a child of another control with any padding set, the docked control completely ignores the padding of the container control. This does not happen if the container control is a subclass of type UserControl.

For example, consider the following two classes.

[Designer("System.Windows.Forms.Design.ParentControlDesigner, System.Design", typeof(IDesigner))]
public class Container : Control
{
    public Container()
    {
        Dock = DockStyle.Fill;
        Padding = new Padding(30, 30, 30, 30);
        BackColor = Color.Blue;
        Controls.Add(new Contained());
    }
}

public class Contained : Control
{
    public Contained()
    {
        Dock = DockStyle.Fill;
        BackColor = Color.White;
    }
}

The DesignerAttribute is simply for use as an aid in the designer. Unless you change the Container control to inherit from UserControl, a Contained control will not conform to the Container control’s Padding property.

Why is this? Do I have to use UserControl in order to dock another control in a custom control with a custom padding?

Note: I am running VS11 with .NET 4.5. This could be the problem, but I can’t test it on another version or platform to find out for sure.

Thanks,
Brandon

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T08:22:10+00:00Added an answer on June 3, 2026 at 8:22 am

    A container control should derive from the ContainerControl class. That gives it a number of “act like a container” behaviors. Including observing the Padding property.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is there any way to dock a Silverlight control to the browser window? For
I have a simple dialog with tab control whit property Dock = Fill. On
VariableBox = gcnew ListView(); VariableBox->Font = ScriptEditorOptions->FontSelection->Font; VariableBox->Dock = DockStyle::Fill; VariableBox->BorderStyle = BorderStyle::Fixed3D; VariableBox->BackColor
I want a tab control to dock to the entire window panel, in Qt
I've created a user control (in vb.net code) that contains two dock panels, one
Version Control with Subversion recommends the following layout for (single-project) repositories (complemented by this
How do I add padding, or some space between the textboxes when using dockstyle.top
trying to run this basic form control example on msdn. At step 1 of
I use this code to show user control on main form private void MainForm_Load(object
Does anyone know why my tabcontrol will not display on this form? Have a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.