gpt4 book ai didi

c# - 为什么这段调整 .NET 窗体高度的代码会使窗体太小?

转载 作者:行者123 更新时间:2023-11-30 14:20:40 25 4
gpt4 key购买 nike

我的意图是表单的大小足以显示整个“buttonOK”,但不要大太多。实际发生的是调整大小的表单最终变小,甚至根本无法显示按钮。

public MyFormDlg()   
{
InitializeComponent();
this.Height = this.buttonOK.Bounds.Bottom + SomePadding;

最佳答案

Height 属性包括窗口标题栏的高度,因此客户区(按钮边界相对的区域)比您预期的要小。

这个有效:

this.ClientSize = new Size(this.ClientSize.Width,
this.buttonOK.Bounds.Bottom + SomePadding);

我没有找到 ClientHeight 属性,这可以做得更简单吗?

关于c# - 为什么这段调整 .NET 窗体高度的代码会使窗体太小?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1002866/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com