欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  IT编程

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

程序员文章站 2023-12-18 23:37:22
本文实例讲述了c# winform实现的气泡提示窗口功能。分享给大家供大家参考,具体如下: using system; using system.collect...

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

using system;
using system.collections.generic;
using system.componentmodel;
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#相关内容感兴趣的读者可查看本站专题:《c#窗体操作技巧汇总》、《winform控件用法总结》、《c#数据结构与算法教程》、《c#常见控件用法教程》、《c#面向对象程序设计入门教程》及《c#程序设计之线程使用技巧总结

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

上一篇:

下一篇: