Reputation: 125
I have been looking into using a generic resizing and repositioning feature into my game, I am creating, based on the window size. My problem is I haven't found a proper function that will regulate a controls size and position based on it's parents original size, new size and set of directions (such as allow resize Y and or X, disallow resize w and or y, allow reposition x and or y, disallow reposition x and or y). I was considering making my own generic function for it and i probably could but when i tested at first it came up with only problematic results where the controls resized not properly. I don't expect anyone to create any code to do this I was just curious if there was a function already out there for it rather then reinventing the wheel.
Upvotes: 2
Views: 105
Reputation: 873
Using Control.Dock Property
yourControl.Dock = DockStyle.Fill
so it'll resize according to it's parent.
Upvotes: 3
Reputation: 34539
You've not gone into a huge amount of detail in your question, but you can Anchor controls in WinForms which will cause them to automatically resize as the size of the parent changes. Alternatively you could also use Dock.Fill which will tell your control to fill it's parent container and will resize in a similar way to anchoring.
Upvotes: 3