Reputation: 5961
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.
Upvotes: 0
Views: 1710
Reputation: 50028
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'
Upvotes: 2
Reputation: 2144
Have you considered using a Flowlayout Panel?
http://msdn.microsoft.com/en-us/library/system.windows.forms.flowlayoutpanel.aspx
Upvotes: 0
Reputation: 62265
Hmm... Even if it seems strange to me that origin "shifts", try aftrr that you added last TextBox add your Delta from its Bounds.Bottom which will generate Top of next TextBox to add.
Hope this helps.
Upvotes: 0