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

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

添加一个notifyIcon控件

vb.net

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

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

Me.WindowState = FormWindowState.Normal
End Sub

c#.net

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

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

}
}

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

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

WindowState = FormWindowState.Normal; }

原文链接:https://www.f2er.com/vb/260156.html

猜你在找的VB相关文章