pmacario
Newcomer
Hello and thank you in advance to anyone that reads this who may be able to shed some light on the problem.
Now onto the problem:
I have a panel (let's call it panelA) on my Windows form, and I am programmatically adding my own user controls (let's call the user control class myUC) at run-time to panelA's Controls collection. I am doing this in the event handler for a button's Click event. Let's call the button btnAdd. So each time btnAdd is clicked, I do the following in its event handler:
1) add a new myUC() to panelA's Controls collection
2) call a helper method to set the Locations of all the myUC's on panelA (the only controls on panelA are myUC's)
The helper method takes in a single argument of type System.Windows.Forms.Panel which is the panel whose controls are to be re-ordered/re-drawn on the panel.
The Problem:
Sometimes when the myUC's are redrawn on the panel, (although their order and spacing is preserved) there is space from the top of the panel to the top of the first myUC. The myUC's when re-drawn are supposed be start at the top of the panel (0,0). However, sometimes when they re-draw, they appear halfway down the panel. Now I've tried to create new Points and se their location that way. I've also tried to maintain an "anchor" user control on the panel and set the "anchor" user control's Visible property to false. Then, using the "anchor" as a reference point, I tried to set the locations of the dynamically-added myUC's relative to the "anchor," but the problem still exists. Also, I've checked the locations of the controls when they re-draw halfway down the panel, and they actually *think* they're starting at location (0,0)! I really don't know what I'm doing wrong. Any help would be greatly appreciated. Also, if you need to see code, let me know, as I can either post or email a sample Windows Forms application.
Again, thanks in advance.
Now onto the problem:
I have a panel (let's call it panelA) on my Windows form, and I am programmatically adding my own user controls (let's call the user control class myUC) at run-time to panelA's Controls collection. I am doing this in the event handler for a button's Click event. Let's call the button btnAdd. So each time btnAdd is clicked, I do the following in its event handler:
1) add a new myUC() to panelA's Controls collection
2) call a helper method to set the Locations of all the myUC's on panelA (the only controls on panelA are myUC's)
The helper method takes in a single argument of type System.Windows.Forms.Panel which is the panel whose controls are to be re-ordered/re-drawn on the panel.
The Problem:
Sometimes when the myUC's are redrawn on the panel, (although their order and spacing is preserved) there is space from the top of the panel to the top of the first myUC. The myUC's when re-drawn are supposed be start at the top of the panel (0,0). However, sometimes when they re-draw, they appear halfway down the panel. Now I've tried to create new Points and se their location that way. I've also tried to maintain an "anchor" user control on the panel and set the "anchor" user control's Visible property to false. Then, using the "anchor" as a reference point, I tried to set the locations of the dynamically-added myUC's relative to the "anchor," but the problem still exists. Also, I've checked the locations of the controls when they re-draw halfway down the panel, and they actually *think* they're starting at location (0,0)! I really don't know what I'm doing wrong. Any help would be greatly appreciated. Also, if you need to see code, let me know, as I can either post or email a sample Windows Forms application.
Again, thanks in advance.