解决Winform窗体最大化遮盖系统任务栏问题

作者:简简单单 2015-01-18

今天将一个Winform窗体设计成最大化后,运行发现它遮盖了系统任务栏,经多次测试发现原来是同时禁用了最大化按钮且设置窗体边框样式为FormBorderStyle.FixedSingle才会出现这种情况:
 
private void Form1_Load(object sender, EventArgs e)
{
    this.MaximizeBox = false;
    this.FormBorderStyle = FormBorderStyle.FixedSingle;
    this.WindowState = FormWindowState.Maximized;
}

调整下顺序即可解决:

 
private void Form1_Load(object sender, EventArgs e)
{
    this.WindowState = FormWindowState.Maximized;
    this.MaximizeBox = false;
    this.FormBorderStyle = FormBorderStyle.FixedSingle;           
}

没想到吧其实就是顺序问题了,这个小编以前在做一些php程序时也因碰到顺序问题导致页面不正常了像js也有碰到过了。

相关文章

精彩推荐