write code for system tray application

Posted by Rajni.Shekhar under C# category on | Points: 40 | Views : 1921
1. create a windows application using c# language
2. declare variables in class (Form1.cs)

private NotifyIcon objIcon;
private ContextMenu objMenu;

3. in constructor

public Form1()
//create tray menu here
objMenu = new ContextMenu();

//add methods with menu
objMenu.MenuItems.Add("Create File", CreateFile); // CreateFile a method to create file
objManu.MenuItems.Add("Close", CloseApp); //CloseApp to exit from application

objIcon= new NotifyIcon();
objIcon.Text = "TrayApplication";
objIcon.Icon = new Icon(SystemIcons.Application, 40, 40);

objIcon.ContextMenu = objManu;


private void CreateFile(object sender, EventArgs e)
//write code to create files
private void CloseApp(object sender, EventArgs e)

Comments or Responses

Login to post response