好得很程序员自学网

<tfoot draggable='sEl'></tfoot>

C# winForm实现的气泡提示窗口功能示例

本文实例讲述了c# winform实现的气泡提示窗口功能。分享给大家供大家参考,具体如下:

?

using system;

using system.collections.generic;

using system测试数据ponentmodel;

using system.data;

using system.drawing;

using system.text;

using system.windows.forms;

namespace windowsformsapplication60

{

   public partial class form1 : form

   {

     private button btnshow = null ;

     private button btnclose = null ;

     private notifyicon notifyicon1 = null ;

     public form1()

     {

       initializecomponent();

       this .load+= new eventhandler(form1_load);

     }

     private void form1_load( object sender, eventargs e)

     {

       btnshow = new button(); //显示气泡提示窗口

       btnshow.text = "show" ;

       btnshow.click += new eventhandler(btnshow_click);

       btnshow.location = new point(10, 10);

       this .controls.add(btnshow);

       btnclose = new button(); //影藏气泡提示窗口

       btnclose.text = "close" ;

       btnclose.click += new eventhandler(btnclose_click);

       btnclose.location = new point(10 + btnshow.width + 10, 10);

       this .controls.add(btnclose);

       notifyicon1 = new notifyicon();

       notifyicon1.mousemove += new mouseeventhandler(notifyicon1_mousemove);

       notifyicon1.icon = global::windowsformsapplication60.properties.resources.lintway;

     }

     /// <summary>

     /// 鼠标移过显示时间

     /// </summary>

     /// <param name="sender"></param>

     /// <param name="e"></param>

     void notifyicon1_mousemove( object sender, mouseeventargs e)

     {

       this .notifyicon1.showballoontip(1000, "当前时间:" , datetime.now.tolocaltime().tostring(), tooltipicon.info); //显示气泡提示

     }

     /// <summary>

     /// 影藏时间

     /// </summary>

     /// <param name="sender"></param>

     /// <param name="e"></param>

     void btnclose_click( object sender, eventargs e)

     {

       this .notifyicon1.visible = false ; //设置提示控件不可见

     }

     /// <summary>

     /// 显示时间

     /// </summary>

     /// <param name="sender"></param>

     /// <param name="e"></param>

     void btnshow_click( object sender, eventargs e)

     {

       this .notifyicon1.visible = true ; //设置提示控件可见

       this .notifyicon1.showballoontip(1000, "当前时间:" , datetime.now.tolocaltime().tostring(), tooltipicon.info); //显示气泡提示

     }

   }

}

希望本文所述对大家c#程序设计有所帮助。

原文链接:https://blog.csdn.net/chadcao/article/details/7183781

dy("nrwz");

查看更多关于C# winForm实现的气泡提示窗口功能示例的详细内容...

  阅读:45次