C# 如何隐藏窗体 懂的进

来源:百度知道 编辑:UC知道 时间:2024/06/24 14:49:26
如何隐藏窗体.如题.
就像QQ主窗体那样.(不是登陆窗体,外行不要进来啦).
不是什么hide().那个是小孩子玩的把戏.

是用什么事件,还是有什么属性.

告诉下.OK.谢.

你指的是像QQ那样最小化成托盘吧。如果是可以用首先:当然要引入NotifyIcon控件。工具箱内有该控件,如果你有点基础能看懂下面代码
private System.Windows.Forms.NotifyIcon notifyIconServer;
this.notifyIconServer = new System.Windows.Forms.NotifyIcon(this.components);

接下来设置控件的各项属性:
//
// notifyIconServer
//
this.notifyIconServer.ContextMenu = this.contextMenuTray;//指定上下文菜单
this.notifyIconServer.Icon = ((System.Drawing.Icon)(resources.GetObject(notifyIconServer.Icon)));//指定图标
this.notifyIconServer.Text = My Server;//指定鼠标悬停显示
this.notifyIconServer.MouseDown += new System.Windows.Forms.MouseEventHandler(this.notifyIconServer_MouseDown);
this.notifyIconServer.DoubleClick += new System.EventHandler(this.notifyIconServer_DoubleClick);

//
// contextMenuTray 上下文菜单
//
this.contextMenuTray.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
this.menuItem1,
this.menuItem2});
// <