How to align the control in the centre.
-
I have made some user controls. I will be using them in another application in C# where these will be added on the form dynamically at the click of a button. The sizes of the user controls differ from one another. The problem is that when I add them dynamically it aligns itself at the top left corner. I want it to automatically align itself to centre of the main form and when I resize the form, it should realign itself. I have tried setting its dock property to fill but it doesn't help at all.
Always Keep Smiling. Yours Pankaj Nikam
-
I have made some user controls. I will be using them in another application in C# where these will be added on the form dynamically at the click of a button. The sizes of the user controls differ from one another. The problem is that when I add them dynamically it aligns itself at the top left corner. I want it to automatically align itself to centre of the main form and when I resize the form, it should realign itself. I have tried setting its dock property to fill but it doesn't help at all.
Always Keep Smiling. Yours Pankaj Nikam
use Resize event of form and put all controls in a panel then update its location. eg
panel.Location = new Point(this.Width/2 - panel.Width/2, this.Height/2-panel.Height/2);
TVMU^P[[IGIOQHG^JSH`A#@`RFJ\c^JPL>;"[,*/|+&WLEZGc`AFXc!L %^]*IRXD#@GKCQ`R\^SF_WcHbORY87֦ʻ6ϣN8ȤBcRAV\Z^&SU~%CSWQ@#2 W_AD`EPABIKRDFVS)EVLQK)JKSQXUFYK[M`UKs*$GwU#(QDXBER@CBN% Rs0~53%eYrd8mt^7Z6]iTF+(EWfJ9zaK-iTV.C\y<pjxsg-b$f4ia> -------------------------------------------------------- 128 bit encrypted signature, crack if you can
-
use Resize event of form and put all controls in a panel then update its location. eg
panel.Location = new Point(this.Width/2 - panel.Width/2, this.Height/2-panel.Height/2);
TVMU^P[[IGIOQHG^JSH`A#@`RFJ\c^JPL>;"[,*/|+&WLEZGc`AFXc!L %^]*IRXD#@GKCQ`R\^SF_WcHbORY87֦ʻ6ϣN8ȤBcRAV\Z^&SU~%CSWQ@#2 W_AD`EPABIKRDFVS)EVLQK)JKSQXUFYK[M`UKs*$GwU#(QDXBER@CBN% Rs0~53%eYrd8mt^7Z6]iTF+(EWfJ9zaK-iTV.C\y<pjxsg-b$f4ia> -------------------------------------------------------- 128 bit encrypted signature, crack if you can
Thank you so much. :)
Always Keep Smiling. Yours Pankaj Nikam
-
I have made some user controls. I will be using them in another application in C# where these will be added on the form dynamically at the click of a button. The sizes of the user controls differ from one another. The problem is that when I add them dynamically it aligns itself at the top left corner. I want it to automatically align itself to centre of the main form and when I resize the form, it should realign itself. I have tried setting its dock property to fill but it doesn't help at all.
Always Keep Smiling. Yours Pankaj Nikam
Put everything into a panel, and set that panel's
Anchor
property to none.Luis Alonso Ramos Intelectix Chihuahua, Mexico My Blog!