Library code snippets
Using the NotifyIcon control
Drag the NotifyIcon control onto your form from the toolbox. Now to initialize the notify icon, the code is pretty simple it goes like this.
//SET THE BASICS UP
notifyIcon1.Icon = new System.Drawing.Icon (@"c:\1.ico");
notifyIcon1.Visible = true;
notifyIcon1.Text = "Test Notify Icon Demo";
You can set the above properties in design time aswell by using the properties window, to hide the notifyIcon you need to set the notifyIcon1.visible = false. You can add click and double click events to the icon by simply inserting this code into the private void InitializeComponent() part of the form:
this.notifyIcon1.DoubleClick += new System.EventHandler(this.notifyIcon1_DoubleClick);
You can now use the below code to show the double click on the icon:
private void notifyIcon1_DoubleClick(object sender, System.EventArgs e)
{
MessageBox.Show("Icon Notify Double Clicked");
}
Now you will probably say great I can change the icon when an event happens in the program and I can see when the user has clicked on the icon to fire other events but how can i add a menu to the icon? Well its pretty simple you can use the ContextMenu control. As before drag and drop this control from the toolbox onto the form, a white container will appear at the top of the active form from where you can enter the menu items. To add this ContextMenu to the NotifyIcon you code it like
notifyIcon1.ContextMenu = contextMenu1;
The ContextMenu events work as they do with any other function calling the ContextMenu, by this i mean you create a event hander:
this.menuItem2.Click += new System.EventHandler(this.menuItem2_Click);
and then code the click like this:
private void menuItem2_Click(object sender, System.EventArgs e)
{
MessageBox.Show("MenuItem2 Clicked");
}
Related articles
Related discussion
-
Buy cheap Xanax overnight. Cheap Xanax. Overnight delivery of Xanax in US no prescription needed. Cheapest Xanax.
by asleymar (0 replies)
-
Buy Soma online without a prescription. Soma drug no prescription. How to get Soma prescription. Soma cod accepted.
by asleymar (0 replies)
-
Cheap online order Fioricet. Cheap discount Fioricet. Offshore Fioricet online. How to buy Fioricet online without a prescription.
by asleymar (0 replies)
-
Buy Ambien no visa without prescription. Not expensive Ambien prescriptions. Ambien no rx. Cod delivery Ambien.
by asleymar (0 replies)
-
Tramadol without doctor rx. Buy Tramadol over the counter cod overnight. Cheap Tramadol cod delivery. Buy Tramadol from mexico online.
by asleymar (0 replies)
Related podcasts
-
Object-Oriented Programming in Ruby
In this episode, I talk with Scott Bellware about object-oriented programming in Ruby, and Ruby's object model. This is taken from a private conversation, and the audio quality suffers at times. Much thanks to Scott for allowing this to be released.This episode of the Alt.NET Podcast is bro...
This thread is for discussions of Using the NotifyIcon control.