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

  • Home
  • SEARCH
  • 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 259575
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T22:16:32+00:00 2026-05-11T22:16:32+00:00

I am trying to make my own user control and have almost finished it,

  • 0

I am trying to make my own user control and have almost finished it, just trying to add some polish. I would like the option in the designer to “Dock in parent container”. Does anyone know how to do this I can’t find an example. I think it has something to do with a Docking Attribute.

  • 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-05-11T22:16:32+00:00Added an answer on May 11, 2026 at 10:16 pm

    I order to achieve this you will need to implement a couple of classes; first you will need a custom ControlDesigner and then you will need a custom DesignerActionList. Both are fairly simple.

    The ControlDesigner:

    public class MyUserControlDesigner : ControlDesigner
    {
    
        private DesignerActionListCollection _actionLists;
        public override System.ComponentModel.Design.DesignerActionListCollection ActionLists
        {
            get
            {
                if (_actionLists == null)
                {
                    _actionLists = new DesignerActionListCollection();
                    _actionLists.Add(new MyUserControlActionList(this));
                }
                return _actionLists;
            }
        }
    }
    

    The DesignerActionList:

    public class MyUserControlActionList : DesignerActionList
    {
        public MyUserControlActionList(MyUserControlDesigner designer) : base(designer.Component) { }
    
        public override DesignerActionItemCollection GetSortedActionItems()
        {
            DesignerActionItemCollection items = new DesignerActionItemCollection();
            items.Add(new DesignerActionPropertyItem("DockInParent", "Dock in parent"));
            return items;
        }
    
        public bool DockInParent
        {
            get
            {
                return ((MyUserControl)base.Component).Dock == DockStyle.Fill;
            }
            set
            {
                TypeDescriptor.GetProperties(base.Component)["Dock"].SetValue(base.Component, value ? DockStyle.Fill : DockStyle.None);
            }
        }    
    }
    

    Finally, you will need to attach the designer to your control:

    [Designer("NamespaceName.MyUserControlDesigner, AssemblyContainingTheDesigner")]
    public partial class MyUserControl : UserControl
    {
        // all the code for your control
    

    Brief explanation

    The control has a Designer attribute associated with it, which points out our custom designer. The only customization in that designer is the DesignerActionList that is exposed. It creates an instance of our custom action list and adds it to the action list collection that is exposed.

    The custom action list contains a bool property (DockInParent), and creates an action item for that property. The property itself will return true if the Dock property of the component being edited is DockStyle.Fill, otherwise false, and if DockInParent is set to true, the Dock property of the component is set to DockStyle.Fill, otherwise DockStyle.None.

    This will display the little “action arrow” close to the upper right corner of the control in the designer, and clicking the arrow will pop up the task menu.

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

Sidebar

Related Questions

Trying to make a make generic select control that I can dynamically add elements
I'm trying to make my own control in for .NET using VB and I'm
I'm trying to make a context menu for a control that is linked to
I am trying to make an Outlook 2003 add-in using Visual Studio 2008 on
I'm trying to make Core Data objects inherit from my own custom class rather
I've got an small issue, I'm trying to make my own forum, but I
I'm trying to make a jquery tooltip that appears when a user mouses over
Trying to make a MySQL-based application support MS SQL, I ran into the following
Trying to make a generic PL/SQL procedure to export data in specific XML format,
Trying to make a web service call to an HTTPS endpoint in my Silverlight

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.