I have a panel and a button that adds text boxes to the panel in the following configuration:
| textbox1 |
| textbox2 |
etc.
The vertical width of each textbox is 27 so what I do is keep track of a y-coordinate and add 30 to it every time I make a new textbox, and put the textbox at that y coordinate. The problem is that after a few textboxes a scrollbar appears, and when I add a new textbox, the origin is taken to be at the top left corner of the visible portion of the panel, not the top left corner of the complete panel. This results in a lot of space between some textboxes. Can anyone help me fix this? Thank you.
I would use a FlowLayoutPanel instead. Then you could just add your textboxes by doing
flowLayoutPanel1.Controls.Add(mytextbox1);The other option is explained in this post.
Another example is Setting position of a control doesn’t seem to work when scroll is ‘moved’