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