Home arrow VB.Net arrow Page 5 - Simple VB.NET Notify Icon with Panel Application
VB.NET

Simple VB.NET Notify Icon with Panel Application


Vikrant's article steps you through the process of building your own Notify Icon application, allowing you to run applications from the task tray, using VB.NET.

Author Info:
By: R. Abhiram Vikrant
Rating: 4 stars4 stars4 stars4 stars4 stars / 130
October 05, 2003
TABLE OF CONTENTS:
  1. · Simple VB.NET Notify Icon with Panel Application
  2. · Notify What?
  3. · The Application
  4. · Context Menu
  5. · Let's Get Cookin'!
  6. · The Code

print this article
SEARCH DEVARTICLES

Simple VB.NET Notify Icon with Panel Application - Let's Get Cookin'!
(Page 5 of 6 )

We’ll now switch our attention to the coding aspect, where we will apply the programming logic.  Select the form and double click it, the code in the “code view” will provide you with the Form_Load event handler and enter the code as shown below.

  Private Sub Form1_Load (ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

        nfi.Visible = False   'hide the icon when the form loads
        Panel1.Visible = True   ' show only Panel1 during the start
        Panel2.Visible = False   'hide the panel2 

End sub

Double click the button labeled Panel1; the code below will be displayed in the code view:

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

    End Sub

We want the above sub-routine to be executed when pan1 (context menu item)   is clicked, so add the following click event to the above code and it goes as:

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click,pan1.click

Hence this sub will be triggered either when the button is clicked or when the Notify Icon menu item Panel1 (pan1) is clicked.

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click,pan1.click

Me. Visible = True 'make sure that the form is displayed first if it's been triggered from notify icon
Panel1.Visible = True ' activate the first panel
Panel2.Visible = False ' hide the second panel
End Sub

Do the same for the Button2_click event handler.  In the code view there will be two drop-down boxes with the components name in them.  The left-hand drop-down box lists the components in the current form and the right-hand drop-down box lists the methods of selected components.

From the left-hand box select the LinkLabel1 control.  From the right-hand select the click event.  You will be provided with the link label click event handler which we’ll code here:

Private Sub LinkLabel1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles LinkLabel1.Click

        Me.Visible = False ' hide the form
        nfi.Visible = True ' show the notify icon in the system tray

    End Sub

We want the application to be visible when the Iotify Icon is double clicked, so select the notify icon (nfi) from the drop down box in the code view and select the double click event from the associated events:

Private Sub nfi_DoubleClick(ByVal sender As Object, ByVal e As System.EventArgs) Handles nfi.DoubleClick

Me.Visible = True
nfi.Visible = False

    End Sub

Select the exit menu item and double click it.

Private Sub MenuItem1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MenuItem1.Click

Me.close()

    End Sub

Bingo! We are done now. Build the application and run it. The complete run of the code follows next:


blog comments powered by Disqus
VB.NET ARTICLES

- MyClass - Implementing Polymorphism in VB.Net
- Building a News Ticker Using VB.Net
- Everything You Wanted to Know About Forms In...
- Building Assemblies with VB.Net
- Simple VB.NET Notify Icon with Panel Applica...
- Regular Expressions in .NET
- String Encryption With Visual Basic .NET
- Deploying Applications in VB.NET: Part 1/2
- Watching Folder Activity in VB.NET
- Creating A Windows Service in VB.NET
- Implementing The Google Web Service In VB.NET
- Migrating to Visual Basic.NET from Visual Ba...

Watch our Tech Videos 
Dev Articles Forums 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
Contact Us 
Site Map 
Privacy Policy 
Support 

Developer Shed Affiliates

 




© 2003-2017 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap
Popular Web Development Topics
All Web Development Tutorials