-
UI resizing
hello all,
I am new to C Sharp development, I have experience in Java and C++ programming. I am currently developing a program for our plc controller. Could someone please advise me how to resize the controls on a Windows form when the form is either being resized or being maximised.
What I want is for my UI elements like buttons, data grid to maintain their relative positions within the Windows form however when the form is either resize or maximised I want these controls to grow with them and occupy the whole screen space like it does in other programming environments such as C++ or Java. Thank you in advance.
-
Re: UI resizing
-
Re: UI resizing
Cannot view screenshot from where I am, but seems your problem can be solved with anchor property.
Example :
Code:
this.textBox.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
Anchor allows you to attach a control to a side of the GUI. Imagine a real chain linking the item to the border chosen.
When you anchor something to the right only it'll keep it's position relative to the right border and moves as the form will be resized.
If you tie it both to left and right at same time, the item will be expanded/collapsed as your form is resized.
(if you're using Visual Studio, check the property window of each GUI object)
-
Re: UI resizing
thank you , yes I remember now it was , I did come across it few years back , just could not remember the name.
-
Re: UI resizing
Seems to work for re size event how about maximize , ( button ) at the top right hand side of the window
-
Re: UI resizing
Works the same like a resize in all directions