Create a Utility Box in Windows Application

Today here, I am describing how to create a Utility Box in Windows Application to open Digital Clock, Calculator, NotePad, Microsoft Word and OutLook inside windows form application.

Here, I have created my windows form like this.

windows

Here, I have taken Button and within that button. I have set url for image of the button.

Button and within that button

Under Digital clock button click write the following code for showing time.

  1. private void button6_Click(object sender, EventArgs e)  
  2. {  
  3.     Label namelabel = new Label();  
  4.     namelabel.Location = new Point(200, 20);  
  5.     // namelabel.Text = nam  
  6.     this.Controls.Add(namelabel);  
  7.     namelabel.Text = System.DateTime.Now.ToLongTimeString();  
  8. }

Here after clicking it show the time as follow.

show the time

Now after clicking the "OUTLOOK" button write that following code for showing the outlook inside the windows form.

  1. private void button5_Click(object sender, EventArgs e)  
  2. {  
  3.     CreateMailItem();  
  4. }  
  5.   
  6. private void CreateMailItem()  
  7. {  
  8.     Microsoft.Office.Interop.Outlook.Application oApp = new Microsoft.Office.Interop.Outlook.Application();  
  9.     Microsoft.Office.Interop.Outlook.MailItem mailItem = (Microsoft.Office.Interop.Outlook.MailItem) oApp.CreateItem(Microsoft.Office.Interop.Outlook.OlItemType.olMailItem);  
  10.     mailItem.Subject = "This is the test message";  
  11.     mailItem.To = "[email protected]";  
  12.     mailItem.CC = "[email protected]";  
  13.     mailItem.Body = "This is the test message";  
  14.     mailItem.Importance = Microsoft.Office.Interop.Outlook.OlImportance.olImportanceNormal;  
  15.     mailItem.Display(false);  
  16.     mailItem = null;  
  17.     oApp = null;  
  18. }

Now after clicking Outlook button it will show the outlook as follow.

Outlook

For generating Microsoft word just write the following code on double click the Microsoft word button.

  1. private void button3_Click(object sender, EventArgs e)  
  2. {  
  3.    System.Diagnostics.Process.Start("winword");  
  4. }

So it will show the word as following.

word

Now for calculator write the following code on calculator button click.

  1. private void button1_Click(object sender, EventArgs e)  
  2. {  
  3.    System.Diagnostics.Process.Start("calc");  
  4. }

calculator

For NotePad write the following code.

  1. private void button2_Click(object sender, EventArgs e)  
  2. {  
  3.    System.Diagnostics.Process.Start("notepad");  
  4. }

NotePad

Now for Logout the application write the following code.

  1. private void button7_Click(object sender, EventArgs e)  
  2. {  
  3.     if (MessageBox.Show("Do you Want to Exit?""Confirm Box", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2) == DialogResult.Yes)  
  4.     {  
  5.         this.Close();  
  6.     }  
  7.     else  
  8.     {}  

So it will show like this.

utility box

Thus in this way we can create the utility box.