如何使用C#在启动时隐藏Windows窗体并在按下快捷键后取消隐藏 [英] How to hide a windows form from start-up using C# and unhide after pressed shortcut key

查看:309
本文介绍了如何使用C#在启动时隐藏Windows窗体并在按下快捷键后取消隐藏的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨 我正在创建一个有条件的Windows窗体应用程序,如果条件为true,则不应该显示该窗体;否则,如果该窗体处于隐藏位置,则应在按下一些快捷键后将其可见( (例如Ctrl + s,Alt + s),因此请建议我该怎么做.

谢谢
Prafulla

Hi I am creating an windows form application which is having a condition, if the condition is true the form shouldn''t be display if not it should display.Now if the form is in hiding position then it should visible after pressed some shortcut key(like Ctrl+s,Alt+s) so please suggest me how would I do that.

Thanks
Prafulla

推荐答案

如果在表单加载中没有条件,则可以使用if条件,如果它背后没有任何事件,则只能在表单加载this.hide();中使用,否则使用if条件
You can use if conditions on form load if you have not any event behind it then you can only use in form load this.hide(); otherwise you use if condition
if(your conditions)
{
    this.hide();
} 
else
{
    this.show(); //or this.visibility = true;
}


在表单加载事件中..
In you form load event..
private void Form1_Load(object sender, EventArgs e)
{
    if (your_condition == false)
        this.Show();
    else
        this.Close();
}


这篇关于如何使用C#在启动时隐藏Windows窗体并在按下快捷键后取消隐藏的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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