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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T15:55:57+00:00 2026-05-14T15:55:57+00:00

How do I add padding, or some space between the textboxes when using dockstyle.top

  • 0

How do I add padding, or some space between the textboxes when using dockstyle.top property?

for(int i =0; i< 10; i++) {
    textboxes[i] = new TextBox();
    textboxes[i].Dock = DockStyle.Top;
    mypanel.Controls.Add(textboxes[i]); 
}

The code above puts textboxes right beneath each other. Can’t figure this out without using mass panels or fixed positioning. How to do the following?

1) I would like to add around 10-20pixels between boxes.

2) How to change size (height,width) of the textboxes, since when using dockstyle.top it ignores the size commands ?

  • 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-14T15:55:57+00:00Added an answer on May 14, 2026 at 3:55 pm

    With DockStype.Top you can’t change the width of your TextBoxes, cause they are docked. You can only change the height. But to change the height of a TextBox you have to set the Multiline = true beforehand.

    To get the space between the different boxes you have to put each TextBox within a panel, set the TextBox.Dock = Fill, the Panel.Dock = Top and the Panel.Padding = 10. Now you have some space between each TextBox.

    Sample Code

    for (int i = 0; i < 10; i++)
    {
        var panelTextBox = CreateBorderedTextBox();
    
        this.Controls.Add(panelTextBox);
    }
    
    private Panel CreateBorderedTextBox()
    {
        var panel = CreatePanel();
        var textBox = CreateTextBox();
    
        panel.Controls.Add(textBox);
        return panel;
    }
    
    private Panel CreatePanel()
    {
        var panel = new Panel();
        panel.Dock = DockStyle.Top;
        panel.Padding = new Padding(5);
    
        return panel;
    }
    
    private TextBox CreateTextBox()
    {
        var textBox = new TextBox();
        textBox.Multiline = true;
        textBox.Dock = DockStyle.Fill;
    
        return textBox;
    }
    

    What i forgot, you can also give a try to the FlowLayoutPanel. Just remove the DockStyle.Top from the panels and put them into the FlowLayoutPanel. Also you should set the FlowDirection to TopDown. Maybe this can also help you to solve your problem, too.

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

Sidebar

Related Questions

I am trying to add some padding or space in between each of the
If I add some padding between the border of a control and the content,
How can I add some horizontal padding space without editing my css file? I
I'm trying to add vertical space between some sections of a page by adding
I wan't to add some space between the navigationbar and the content of the
How can I add some padding to a jtextfield? I've tried tf.setMargin(new Insets(5,5,5,5)); which
I want to add padding on UIWebview using Javascript, because I switch the view
Quote from Head first html: You can add padding to the top and bottom
I've got a two column layout that I'd like to add some padding\margin to
I am trying to add some extra padding to the right side of 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.