简体   繁体   中英

Position with one of the textbox in between textboxes

I have a question for positioning one of the textbox between textboxes in windows forms.

This below image:

在此处输入图片说明

From this code:

this.textBox2.Left = (this.ClientSize.Width - this.textBox2.Width) / 2; // Description text box

And this below image:

在此处输入图片说明

From this code:

this.textBox2.Left = this.textBox2.Right / 2; // Description text box

My question is: How can I get the width of the description textbox, so there is only 20 pixels (probably) space between the quantity textbox and the price textbox? Like the two images above, the right and the left side of the description textbox.

You answer much appreciated.

Thank you

Use a TableLayoutPanel to do the layout.

Create a layout with four columns:

  1. Fixed width (product code)
  2. Fixed width (quantity)
  3. 100% (description)
  4. Fixed width (price)

You have to set the Anchor for the controls to Left,Right so they size with their content. (You could probably fix the rest of your form in it too, if that is convenient to you)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM