Click here to Skip to main content
15,892,839 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
Hi all


i am learning how to use the notify control in the form.
C#
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;

namespace NotificationCenter
{
  /// <summary>
  /// Summary description for NotifyIconForm.
  /// </summary>
  public class NotifyIconForm : System.Windows.Forms.Form
  {
    private System.Windows.Forms.NotifyIcon notifyIcon1;
    private System.Windows.Forms.Button button1;
    private System.ComponentModel.IContainer components;

    public NotifyIconForm()
    {
      //
      // Required for Windows Form Designer support
      //
      InitializeComponent();

      //
      // TODO: Add any constructor code after InitializeComponent call
      //
      this.notifyIcon1.DoubleClick += new System.EventHandler(this.notifyIcon1_DoubleClick);
    }

    /// <summary>
    /// Clean up any resources being used.
    /// </summary>
    protected override void Dispose( bool disposing )
    {
      if( disposing )
      {
        if (components != null) 
        {
          components.Dispose();
        }
      }
      base.Dispose( disposing );
    }

    #region Windows Form Designer generated code
    /// <summary>
    /// Required method for Designer support - do not modify
    /// the contents of this method with the code editor.
    /// </summary>
    private void InitializeComponent()
    {
      this.components = new System.ComponentModel.Container();

      this.notifyIcon1 = new System.Windows.Forms.NotifyIcon(this.components);
      this.button1 = new System.Windows.Forms.Button();
      this.SuspendLayout();
      // 
      // notifyIcon1
      // 
      this.notifyIcon1.Text = "Hello from NotifyIconExample";
      // 
      // button1
      // 
      this.button1.Location = new System.Drawing.Point(109, 122);
      this.button1.Name = "button1";
      this.button1.TabIndex = 0;
      this.button1.Text = "Hide in tray";
      this.button1.Click += new System.EventHandler(this.button1_Click);
      // 
      // NotifyIconForm
      // 
      this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
      this.ClientSize = new System.Drawing.Size(292, 266);
      this.Controls.AddRange(new System.Windows.Forms.Control[] {
                                      this.button1});
      this.Name = "NotifyIconForm";
      this.Text = "NotifyIconForm";
      this.ResumeLayout(false);

    }
    #endregion

    /// <summary>
    /// The main entry point for the application.
    /// </summary>
    [STAThread]
    static void Main1() 
    {
      Application.Run(new NotifyIconForm());
    }

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

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

  }
}


I have written this program.When we click on the button this form will disappear and the Notification should show at the right side of the task bar.
But it is not showing anything.When i click on the button the form disappear and nothing is showing .

What should i do show that i can show the notification on the right side of the task bar?
or suggest any good website to learn the use of notify control.

Please help

Thanks in advance
Posted

1 solution

Solved by my self

We have to set a image for the notifyIcon.
Means
VB
//
// notifyIcon1
//
this.ntfyNotification.Icon = ((System.Drawing.Icon)(resources.GetObject("ntfyNotification.Icon")));
this.notifyIcon1.Text = "Hello from NotifyIconExample";


So that the icon is able to show the icon on the taskbar.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900