Search - Articles
DevASP.NET for ASP.NET, VB.NET, XML and C# (C-Sharp) Developers Tuesday, March 03, 2009
Dev Articles
Search Directory
ASP.NET
VB.Net
C-Sharp
SQL Server
 

Working with Tool Bar Control in VB.Net

Author: DevASP
Download Source Code : 366_ToolBox.zip

In this simple article you will learn that how can work with toolbar control.

Create a New Project in VB.net. Drag a ImageList control and tool bar control from tool box and place on form. Now go to properties of the image list and using property collection ADD pictures. Now go to properties of the Tool bar control and using property collection ADD Buttons. Now write code on form load event of the form and some other events as follows

 

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

 

        ToolBar1.ImageList = ImageList1

 

        Me.ToolBarButton1.ImageIndex = 0

        Me.ToolBarButton2.ImageIndex = 1

        Me.ToolBarButton3.ImageIndex = 2

 

        Me.ToolBarButton1.ToolTipText = "Green"

        Me.ToolBarButton2.ToolTipText = "Light Blue"

        Me.ToolBarButton3.ToolTipText = "Gray"

 

End Sub

 

 

Private Sub ToolBar1_ButtonClick(ByVal sender As System.Object, ByVal e As System.Windows.Forms.ToolBarButtonClickEventArgs) Handles ToolBar1.ButtonClick

 

        If e.Button.ImageIndex = 0 Then

            Me.BackColor = Color.Green

        End If

 

        If e.Button.ImageIndex = 1 Then

            Me.BackColor = Color.LightBlue

        End If

 

        If e.Button.ImageIndex = 2 Then

            Me.BackColor = Color.Gray

        End If

 

End Sub

   
Add Article Comment:
Name :
Email Address :
   
Comments :
 
   
<< How to Display Images in ComboBox

Disclaimer - Privacy
© 2002-2017 DevASP.net