locking winform

Ask questions about creating Graphical User Interfaces (GUI) in PowerShell and using WinForms controls.
Forum rules
Do not post any licensing information in this forum.

Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
This topic is 7 years and 1 month old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
Locked
User avatar
sekou2331
Posts: 318
Last visit: Sat Oct 28, 2023 7:46 am

locking winform

Post by sekou2331 »

Product, version and build:Powershell Studio 2017 version: 5.4.134
64 bit version
Operating system: Windows 7
64 bit OS
PowerShell Version: 5

I am new to creating winforms. So i am having issue where I created my GUI on 27" monitor and I am noticing that if it is used on any other smaller sized monitor everything gets moved around or disappears behind other parts of the winform. Also noticed if I resize anything while the form is running nothing shrinks it just disappears. Is there a way to lock the form to a certain size and make everything in the form stay put lol.
User avatar
davidc
Posts: 5913
Last visit: Mon Jul 08, 2019 8:55 am
Been upvoted: 2 times

Re: locking winform

Post by davidc »

[TOPIC MOVED TO POWERSHELL GUIS FORUM BY MODERATOR]
David
SAPIEN Technologies, Inc.
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: locking winform

Post by jvierra »

If you form is created with incorrect docking or anchor or the form is too large for the screen then it will not resize correctly. Be sure your monitor is set to correct settings for Windows and that you have not altered the 96"dpi or are not using an unsupported graphics card or driver.

Start by building a small form that is correctly anchored and test it when deployed. Also be sure your expectations about how Windows manages forms resizing and display on multiple monitors is accomplished. Using extremely high resolutions can make forms development difficult.
User avatar
davidc
Posts: 5913
Last visit: Mon Jul 08, 2019 8:55 am
Been upvoted: 2 times

Re: locking winform

Post by davidc »

The following article covers the Anchor and Dock properties of GUI controls:

http://info.sapien.com/index.php/guis/g ... nd-methods

You can also use a TableLayoutPanel to prevent overlapping:

https://msdn.microsoft.com/en-us/librar ... .110).aspx
David
SAPIEN Technologies, Inc.
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: locking winform

Post by jvierra »

David's links are a very good place to start but, be warned, the graphics settings can make all of this impossible. Check your graphics first then follow the articles for background on how to make a form resize well. If you want all controls to resize with the form then you have to be sure to use controls that can be resized.

I would start by anchoring all controls to the top left of the form so they stay in relation to each other. Once youmaster that then you can look into adding and anchoring resizable controls.
This topic is 7 years and 1 month old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
Locked