如何在c#.net windows应用程序中最小化按钮单击事件中的代码? [英] How to wrice code in minimize button click event in c# .net windows application?

查看:92
本文介绍了如何在c#.net windows应用程序中最小化按钮单击事件中的代码?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,



我想在c#.net windows应用程序中编写最小化按钮点击事件的代码。



怎么可能?



请帮帮我。对我来说非常紧急。



谢谢。



Ankit Agarwal

软件工程师

解决方案

< blockquote>尝试此编辑可以使用调整大小事件来执行此操作,

private void Form1_Resize(对象发送者,EventArgs e)

{

if( this.WindowState == FormWindowState.Minimized)

this.Hide();

}



然后使用FormClosing事件取消关闭并最小化表格如下

private void Form1_FormClosing (对象发送者,FormClosingEventArgs e)

{

if(e.CloseReason == CloseReason.UserClosing)

{

e.Cancel = true;

this.WindowState = FormWindowState.Minimized;

}

}


要检测Minimize操作,请实现SizeChanged事件处理程序并检查WindowState属性。



对于结束操作,为Closed事件实现一个事件处理程序。



在这两种情况下你都可以调用你的函数根据需要。


Hello,

I want to write code on minimize button click event in our c# .net windows application.

How can be possible?

Please help me.It''s a very urgent for me.

Thanks.

Ankit Agarwal
Software Engineer

解决方案

Try this EDIT May use Resize Event to do it,
private void Form1_Resize(object sender, EventArgs e)
{
if (this.WindowState == FormWindowState.Minimized)
this.Hide();
}

Then using the FormClosing Event to cancel Close and minimize the Form as below
private void Form1_FormClosing(object sender, FormClosingEventArgs e)
{
if (e.CloseReason == CloseReason.UserClosing)
{
e.Cancel = true;
this.WindowState = FormWindowState.Minimized;
}
}


To detect the Minimize operation, implement a SizeChanged event handler and check the WindowState property.

For the closing operation, implement an event handler for the Closed event.

In both situations you can invoke your function as required.


这篇关于如何在c#.net windows应用程序中最小化按钮单击事件中的代码?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆