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 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

Ask A Question

Stats

  • Questions 515k
  • Answers 515k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer For your examples, my first approach would be to get… May 16, 2026 at 6:29 pm
  • Editorial Team
    Editorial Team added an answer Check this URL : http://www.diskserialnumber.com/ http://www.diskserialnumber.com/get-disk-serial Better one: http://www.codeproject.com/KB/cs/hard_disk_serialno.aspx May 16, 2026 at 6:29 pm
  • Editorial Team
    Editorial Team added an answer turns out you have to do url_for(...) instead of :url=>{...}… May 16, 2026 at 6:29 pm

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Related Questions

I'm having with some margin or padding issues with IE8 that I'm hoping someone
I making some css buttons and I want to add an icon before the
Is there any way to add 0 margin/padding to a JPanel so it fits
This is so annoying. In Firefox and Opera, I'm getting padding between my nested
I am using WordPress 3.0.1 and the Twenty-ten theme. How can I add spaces
I'm a relative beginner in the WPF space so I'm sure this will be
I'm using StringBuffer in Java to concat strings together, like so: StringBuffer str =
In some page, my side menu is created dynamically like this. <div id=tree class=treeview>
here is the page where i need to add CSS: http://upload.wikimedia.org/wikipedia/commons/a/a5/Map_of_USA_with_state_names.svg since there is
I am not a CSS expert (mainly because I haven’t had the need to

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.