2

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.

4

2 回答 2

3

您的问题没有详细说明,但您可以在 WinForms 中锚定控件,这将导致它们随着父级大小的变化而自动调整大小。或者,您也可以使用 Dock.Fill 来告诉您的控件填充它的父容器,并以与锚定类似的方式调整大小。

在此处输入图像描述

于 2013-08-07T10:34:11.373 回答
3

使用Control.Dock 属性

yourControl.Dock = DockStyle.Fill

所以它会根据它的父母调整大小。

于 2013-08-07T10:39:04.107 回答