DockStyle.Top problems
-
I'm developing this app that allows users to add controls that represent tasks by clicking a button. When the button gets clicked, a new TaskControl is created and added to the TaskPanel container. The TaskControl has a DockStyle.Top. However, when the button gets clicked again to add another TaskControl, the new TaskControl gets added to the TaskPanel above the existing TaskControl(s). I want it to appear below the already existing controls. How do I go about doing that?
-
I'm developing this app that allows users to add controls that represent tasks by clicking a button. When the button gets clicked, a new TaskControl is created and added to the TaskPanel container. The TaskControl has a DockStyle.Top. However, when the button gets clicked again to add another TaskControl, the new TaskControl gets added to the TaskPanel above the existing TaskControl(s). I want it to appear below the already existing controls. How do I go about doing that?
Try calling .BringToFront() on the control you want at the top. Docking orders depend on the Z order of the controls. Play around with the BringToFront and SendToBack methods. #include "witty_sig.h"
-
Try calling .BringToFront() on the control you want at the top. Docking orders depend on the Z order of the controls. Play around with the BringToFront and SendToBack methods. #include "witty_sig.h"
They are already displayed "on top", but the problem is that new controls push the old ones down (not on the z-axis, but on the y-axis). So I see 'em all, but like so (crude lineart :D)
container <-- new one gets inserted here and pushes existing down control --------------------------------
-
I'm developing this app that allows users to add controls that represent tasks by clicking a button. When the button gets clicked, a new TaskControl is created and added to the TaskPanel container. The TaskControl has a DockStyle.Top. However, when the button gets clicked again to add another TaskControl, the new TaskControl gets added to the TaskPanel above the existing TaskControl(s). I want it to appear below the already existing controls. How do I go about doing that?
//Ok your requirement is to add your task control just beneth to the existing task control when //you click the add button. //for eg : if this is your location value of panel control this.yourpannel_control.Location=new System.Drawing.Point(8,0); //then //assign to public variable LocX and LocY (forgetting x and y co-ordinates values) //initial values of LocX and LocY this.LocX=yourpannel_control.Location.X; this.LocY=yourpannel_control.Location.Y+32; //(i gave 32 . you can give any number. based on this value your task control will add from top) buttion_click() { if(_UCtl1==null) { _UCtl1=new yourtask_control() this._UCtl1.Location = new System.Drawing.Point(LocX, LocY); this.yourpannel_control.Controls.Add(_UCtl1); } else { _UCtl1=new new yourtask_control() this._UCtl1.Location = new System.Drawing.Point(LocX, LocY); this.yourpannel_control.Controls.Add(_UCtl1); } LocX=LocX; LocY=LocY+32; yourpannel_control.Height=LocY+16; //(i gave 16. you can give the height of your task control + difference between two task control) } this code will add your task control just one beneth the other.