2016-02-05 69 views
-2
enter code here 


namespace WindowsFormsApplication1 
{ 
public partial class Mainmenu : Form 
{ 
    Sendingmail sm = new Sendingmail(); 

    public Mainmenu() 
    { 
     InitializeComponent(); 

    } 
private void button6_Click(object sender, EventArgs e) 
    { 




     this.WindowState = FormWindowState.Normal; 
     notifyIcon1.Icon = SystemIcons.Exclamation; 
     notifyIcon1.BalloonTipIcon = ToolTipIcon.Info; 
     notifyIcon1.BalloonTipTitle = "Patient medicine"; 
     notifyIcon1.BalloonTipText = "Please be noted that a patient should take his medicine now" + 
            Environment.NewLine + 
            "click on the icon when medicine given"; 

     notifyIcon1.ShowBalloonTip(20000); 
     notifyIcon1.Visible = true; 

    } 

    private void notifyIcon1_MouseDoubleClick(object sender, MouseEventArgs e) 
    { 

     Sendingmail sm = new Sendingmail(); 
     sm.Show(); 

    } 

当我点击显示的通知时,我想要打开一个窗体,我尝试了如上所示的mouseDoubleClick函数,但它也没有工作。 有什么帮助吗?在通知中显示新表单

+0

你能澄清“没有工作”吗?你有没有得到一个错误,或者什么都没有?您是否放置了一个中断点并查看该事件中的代码是否正在执行?您似乎已将一些设计器代码与上面代码片段中的代码隐藏代码混合在一起......这些代码不会按原样编译。 –

+0

Sendingmail sm = new Sendingmail(); sm.Show(); //这就是我所做的,没有发生任何事情,窗体没有打开 –

+0

尝试sm.ShowDialog(); – NickGames

回答

2

您是否在上面声明了sm变量? 尝试在mousedoubleClick中的sm.Show();之前声明表单sm变量。

+0

sm值是我在类中顶部声明的新形式的名称 –

+1

啊好吧,我认为是这样..你能粘贴其余的代码吗?也许这样我们可以更好地帮助你。通常在使用Ashok Patel的代码时它必须工作。 – NickGames

+0

public partial class Mainmenu:表格 { Sendingmail sm = new Sendingmail(); //这是写在beginnig,然后我们有通知代码,然后在上面显示的名为MouseDoubleClick的事件 –

0

双击你应该写如下代码。

private void notifyIcon1_MouseDoubleClick(object sender, MouseEventArgs e) 
{ 
    Form2 sm = new Form2(); 
    sm.Show(); 
} 

//确保您创建SM表单的新对象。

+0

它没有工作的工作。 –

+0

显示整个代码 –

+0

你是否得到任何异常或任何东西?是否在点击时调用该通知事件? –

0

在button6_Click函数底部添加下面的代码。

notifyIcon1.Click += (sender, e) => 
{ 
    Sendingmail sm = new Sendingmail(); 
    sm.Show(); 
};