我编写了一个专为 1280x1024 屏幕设计的 C# Windows 窗体应用程序。它完全充满了控制。我需要为 1024x600 屏幕制作一个“轻型”版本,该版本可以在上网本上使用相同的代码库。我能想到的最简单的方法是 #ifdef 设计文件并定义一些变量以在构建时选择并进行多次构建,但我更愿意在我的解决方案中有第二个项目继承第一种形式的所有内容并且使用设计器重新排列各种列表框、文本框等,也许制作几个选项卡来保存不太相关的信息。在 visual studio 2010 中执行此操作的最简单方法是什么?
请您参考如下方法:
这就是Control.Anchor属性(property)是为了。您需要为希望调整大小的控件设置它。
来自 MSDN:
Use the
Anchorproperty to define how a control is automatically resized as its parent control is resized. Anchoring a control to its parent control ensures that the anchored edges remain in the same position relative to the edges of the parent control when the parent control is resized.You can anchor a control to one or more edges of its container. For example, if you have a
Formwith aButtonwhoseAnchorproperty value is set toTopandBottom, theButtonis stretched to maintain the anchored distance to the top and bottom edges of theFormas theHeightof theFormis increased.
