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 6345201
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T20:46:34+00:00 2026-05-24T20:46:34+00:00

I have a custom form that has 4 panels on it edges. I would

  • 0

I have a custom form that has 4 panels on it edges. I would like to anchor another panel to contain user controls to the visible edges of the form. Once that is done I would then like to anchor an undetermined number of controls to the already anchored panel. I am rather new to this and I do not know that this is the best way to achieve my goal of having a list of objects that resize as the form is resized. The reason I am working at it from this angle is I want the objects to be clickable, and moveable, not just text lines.

My thought is something like this.

----------------------------------------
| Header Panel                         |
----------------------------------------
|| <--left panel         right panel->||
|| [ user control object             ]||
|| [ user control object             ]||
|| [ user control object             ]||
|| [ user control object             ]||
----------------------------------------
| Bottom Panel                         |
----------------------------------------

Currently I am able to draw the panel that holds the user control objects as desired, but it does not resize with the parent, and when I try to anchor it to the parent, it anchors to the wrong place. I have also attempted to anchor the user control objects to the user control panel but they are not resizing at all.

So here is the code for the container panel

//This is called after InitializeComponent(), I would assume the anchor would go 
//in here somewhere, but I need the anchor to be offset by the bounds of the 
//other panels as listed below.
private static void SetQuestionContainerBounds(SessionReviewForm instance)
{
   instance.pnlQuestionContainer.Top = instance.HeaderPanel.Bottom;
   instance.pnlQuestionContainer.Left = instance.LeftPanel.Right;
   instance.pnlQuestionContainer.Width = instance.RightPanel.Left - instance.pnlQuestionContainer.Left;
   instance.pnlQuestionContainer.Height = instance.StatusPanel.Top - instance.pnlQuestionContainer.Top;
}

After I make the form and position the pnlQuestionContainer, I then start making user controls called base question objects, anchor them, and added them to the pnlQuestionContainer

private void DisplayData()
{
// tracks the number of questions, used in placement of objects
int questionCount = 0;

// if the session question is marked for review
// generate a new question object and place it.
foreach (SessionQuestion sq in thisSessionPart.SessionQuestions)
{
    if(sq.MarkForReview)
    {
        BaseQuestionObject bqo = new BaseQuestionObject(sq, parentSession);

        BaseQuestionObject.FitAndPlaceObject(pnlQuestionContainer, bqo, questionCount);

        bqo.Anchor = (AnchorStyles.Left | AnchorStyles.Right);

        pnlQuestionContainer.Controls.Add(bqo);

        questionCount++;
    }
}
}

A base question object is made up of three parts at the moment. A userControl, a group box, and a label. All of these items are set to autosize with anchor of left, right with the exception of the user control as I cant set that in the properties window, but I think i am setting it in the above method.

The current results are that the container panel is drawn perfectly at first, but it never resizes. The question objects are drawn at the same size that they were made, though this is not the max or the min size.


[EDIT]
The issue I had was the anchor styles were not playing nice with autosize. After turning autosize off and manipulating the anchorStyles I was able to get the desired results.

  • 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-24T20:46:34+00:00Added an answer on May 24, 2026 at 8:46 pm

    First, I’m not 100% sure of what you are trying to do but anchoring is much simpler than the way you are trying to achieve it.

    Each control has a property called Anchor which is an AnchorStyles enumeration. These values can be Left, Right, Top, Bottom or None and can be bitwised ORed together to allow for multiple anchoring values.

    The default ‘Anchor’ value is Top-Left. If you change the anchoring to Top-Right your controls will remain the same size, but will “float” with the right-side of your application window as it is resized. If you anchor to the Left, Top and Right, your controls will grow and shrink as you resize the width of your window.

    I do not believe that you should need any of these panels, unless they are used to logically group controls together. You can experiment with the anchoring by placing a bunch of controls on a form and changing their anchor settings. Run your test form and resize it and see what happens.

    Additionally, if you would like to re-arrange the contents of your form as the Window grows and shrinks, the standard MS toolbox has a few controls that you can play around with. Specifically, check out the FlowLayoutPanel and TableLayoutPanel. You can use these controls to fine tune how you want to reposition your child controls on a form or in a section of a form.

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

Sidebar

Related Questions

I have a custom sharepoint aspx form that has an InputFormTextBox with RichText property
I have a user registration form that has a password and confirm password field.
I have a form that has some standard ASP.NET validators and some custom validators.
I have a form and it has tones of other controls(buttons, custom controls, labels,
I have a custom UITableViewCell that has a UISegmentedControl object. My UITableView (questionnaire form)
I have one main windows form and within that form I have custom controls
I have a form that has a submit button in it somewhere. However, I
I have a form that has a Is you billing address the same as
I have written a custom dialog (form) that I can use in a C#
I have a CRUD form that has a select widget. The options in the

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.