Adding dynamicly controls to a Panel
-
Hello, I have the following problem, In a window form I have a panel (with autosroll enabled) and inside this panel I would like to add dynamicly other panels. I have a variable that holds the number of panels inside the main Panel. So whenever I add a new panel,its location is calculated by (number_of_panels+space_between_two_panels)*panel_height The code works fine.. until I scroll down the mainpanel to the bottom, then when I add a new panel inside it there is a huge gap between the last panel and the newly added one. Any one can tell me why? and how to solve it ?(I dont want to scroll the main panel all the way up just to add a new panel). Help appreciated, Pawel
-
Hello, I have the following problem, In a window form I have a panel (with autosroll enabled) and inside this panel I would like to add dynamicly other panels. I have a variable that holds the number of panels inside the main Panel. So whenever I add a new panel,its location is calculated by (number_of_panels+space_between_two_panels)*panel_height The code works fine.. until I scroll down the mainpanel to the bottom, then when I add a new panel inside it there is a huge gap between the last panel and the newly added one. Any one can tell me why? and how to solve it ?(I dont want to scroll the main panel all the way up just to add a new panel). Help appreciated, Pawel
I think you have to somehow consider the value returned by the
AutoScrollPosition
property in your calculation.
"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning." - Rick Cook
-
Hello, I have the following problem, In a window form I have a panel (with autosroll enabled) and inside this panel I would like to add dynamicly other panels. I have a variable that holds the number of panels inside the main Panel. So whenever I add a new panel,its location is calculated by (number_of_panels+space_between_two_panels)*panel_height The code works fine.. until I scroll down the mainpanel to the bottom, then when I add a new panel inside it there is a huge gap between the last panel and the newly added one. Any one can tell me why? and how to solve it ?(I dont want to scroll the main panel all the way up just to add a new panel). Help appreciated, Pawel
Hi, what your are doing sound principally correct and the fact that you have scrolled shouldn't matter. I assume there is some little mistake in your implementation (probably you are using a wrong property at some place). You probably have to post some code. Instead of calculating all positions yourself you could also with
panel.Dock = DockStyle.Top
to the container panel. This way the framework should handle the correct positioning. Robert