I am using a Panel
to hold a list of controls (user-defined). The way that I add the panels, I am setting the location of the control based on the Panel.Controls.Count
before I add it to the panel.
comRec.Location = new Point(comRec.Location.X, panel1.Controls.Count * 25);
panel1.Controls.Add(comRec);
Now, this works nicely and looks exactly the way that I want it to. However, once we reach the limit on the window, the AutoScroll
enables (which I do want). Now, if the user were to scroll to the bottom of the Panel
, this ultimately changes the location of every control in the panel. Instead of my first comRec.Location
being (0,0), it is something like (0,-219). So now, when the user adds another comRec
object, it creates a HUGE gap between the objects.
My question is this, what is the best way to account for the changes of the location with the scrollbar and still using my adding system. I am assuming that will have to do something with checking the value of the scrollbar and using it to determine the location.
Also, is there a BETTER way to display a list of controls? Should I be using a Panel
?
Look at the FlowLayoutPanel control, it's exactly what you what.