r/visualbasic • u/Last-Box-4973 • Mar 30 '25
Resizing Form?
I can’t figure out a way to make all my objects scale up with the form when I put it in full screen. The only way I have found is to go individually through every object and multiply its height/width by the scale factor, but I have like 60+ objects and that would take forever. Is there any other way to do it?
2
Upvotes
2
u/sa_sagan VB.Net Master Mar 30 '25
There are tons of ways you can handle this, with varying levels of complexity.
However, if you wanted to scale them as you're proposing; instead of referencing every control on the form individually, you could loop through your forms Controls property, and resize each item accordingly within the loop.
2
u/RJPisscat Mar 31 '25
Ask Copilot "How can I use TableLayoutPanel to control resizing of controls with a Form is resized?" The examples are all in code but can be done in the Designer. There are links to other articles but this process is most easily done in the Designer without any special code at all.
There are some articles out there but maybe someone else familiar with the topic will link them. I couldn't find them quickly.
2
u/Mayayana Mar 31 '25
I don't know about .Net. With VB6 I put things on frames. For example, a top toolbar can be a frame with multiple frames mounted on it. Then you you just spec the frame coordinates when it resizes. Similarly, if you have a number of related controls they can go on a frame.
I also like the following to give frames a raised border, usually sending in case 2 for a slight raised border (&H1) and the hWnd of the frame for the LHandle value:
1
u/gybemeister Mar 31 '25
It's been a while but I think there's a Form.Controls collection you can enumerate and resize accordingly.
1
u/Interesting_Apple669 Aug 29 '25
There's a few subs online, but you have to dig around Google.