How to trigger the event associated with maximize in C#

核能气质少年 提交于 2019-12-01 21:22:22

In WPF, you can use the WindowState property:

myWindow.WindowState = WindowState.Maximized;

You can of course query that property to obtain the current window state:

if (myWindow.WindowState == WindowState.Maximized) {
    // Window is currently maximized.
}

For WinForms, you can use

bool maximized = this.WindowState == System.Windows.Forms.FormWindowState.Maximized;

to test if the window is maximized.

The SizeChanged and Resize events should capture all changes to the window state.

In WinForms, do

// Code which is effective as pressing the maximize button
myWindow.WindowState = FormWindowState.Maximized;

Of course you can test it the same way:

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