Width not changing when Size changes

我的未来我决定 提交于 2019-12-10 23:54:51

问题


I've been doing this for years. But now it's just not working.

private void Form1_Deactivate(object sender, EventArgs e)
        {
            this.Size = new Size(30, 29);
            txt.Visible = false;
            lbl.Visible = false;
        }

The form just does not change Width. But, as above, the 3 controls DO become invisible.

Any suggestions?


回答1:


Windows have an absolute minimum width of 134 pixels (at least on Windows 7)

To circumvent this minimum, you can set FormBorderStyle to FixedToolWindow or SizableToolWindow. (Or handle Windows messages)




回答2:


First set the FormBorderStyle to SizableToolWindow then set your own value.



来源:https://stackoverflow.com/questions/2879368/width-not-changing-when-size-changes

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!