Stretch (or anchor) multiple objects together

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 5 years and 10 months 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
therider
Posts: 6
Last visit: Tue Jul 03, 2018 9:43 am

Stretch (or anchor) multiple objects together

Post by therider »

Hello,

I want to stretch multiple objects together when a form is stretched.

For example, say the user stretches the form to the right. There are two text boxes left and right of each other on the form. I would want the two text boxes to stretch to fill the empty room.

The issue I'm having is if I anchor box text boxes to both left and right, the stretching makes them overlap each other. I would probably need them to stretch half as much and with the box on the right moving a little bit to make room.

Edit: Also, I can anchor both boxes to top or bottom, and they would at least stay aligned, but wont stretch at all.
User avatar
davidc
Posts: 5913
Last visit: Mon Jul 08, 2019 8:55 am
Been upvoted: 2 times

Re: Stretch (or anchor) multiple objects together

Post by davidc »

I recommend using a TableLayoutPanel for cases like these. You can configure the table's column widths to 50% and the controls will expand without overlap.
David
SAPIEN Technologies, Inc.
User avatar
therider
Posts: 6
Last visit: Tue Jul 03, 2018 9:43 am

Re: Stretch (or anchor) multiple objects together

Post by therider »

Worked perfectly! Thank you.
This topic is 5 years and 10 months 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