vb.net和c#.net最小化到托盘

前端之家收集整理的这篇文章主要介绍了vb.net和c#.net最小化到托盘前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

添加一个notifyIcon控件@H_301_5@

vb.net@H_301_5@

Private Sub vbFormTest_Resize(ByVal sender As System.Object,ByVal e As System.EventArgs) Handles MyBase.Resize
If WindowState = FormWindowState.Minimized Then
Me.Visible = False
Me.NotifyIcon1.Visible = True
End If
End Sub@H_301_5@

Private Sub NotifyIcon1_Click(ByVal sender As System.Object,ByVal e As System.EventArgs) Handles NotifyIcon1.Click
Me.Visible = True
NotifyIcon1.Visible = False@H_301_5@

Me.WindowState = FormWindowState.Normal
End Sub@H_301_5@

c#.net@H_301_5@

//调整窗体大小的时候,如果是最小化,窗体不显示,在托盘中显示@H_301_5@

private void Form1_Resize(object sender,EventArgs e)
{
if (this.WindowState == FormWindowState.Minimized)
{
this.Visible = false;
this.notifyIcon1.Visible = true;

}
}@H_301_5@

//如果点击托盘中的窗体图标,则窗体显示,托盘中的图标隐藏@H_301_5@

private void notifyIcon1_Click(object sender,EventArgs e)
{
this.Visible = true;
this.notifyIcon1.Visible = false;@H_301_5@

WindowState = FormWindowState.Normal; }@H_301_5@ 原文链接:https://www.f2er.com/vb/260156.html

猜你在找的VB相关文章