News:

GinGly.com - Used by 85,000 Members - SMS Backed up 7,35,000 - Contacts Stored  28,850 !!

Main Menu

ImageList control and give it the images

Started by nandagopal, May 18, 2009, 04:28 PM

Previous topic - Next topic

nandagopal

Create an ImageList control and give it the images you want to display on the buttons. To add a picture to the ImageList, select the control, open the Properties window, select the Images property, and click the ellipsis to the left.

Next create the Tollbar control. Set the control's ImageList property to the ImageList control containing the button images. Next select the Buttons property and click the ellipsis to the right. Add buttons and for each set the Style property to PushButton. Also set each button's ImageIndex property to the corresponding picture in the ImageList. (Happily the button collection editor shows you a small image of the picture so it's easy to find the one you need.)

When the user clicks a button the toolbar's ButtonClick event fires. This example toggles the selected button and displays its ToolTipText.


' The currently selected button.
Private m_SelectedButton As ToolBarButton

Private Sub tbrDrawingTools_ButtonClick(ByVal sender As _
    Object, ByVal e As _
    System.Windows.Forms.ToolBarButtonClickEventArgs) _
    Handles tbrDrawingTools.ButtonClick
    ' Unpush the pushed button.
    If Not (m_SelectedButton Is Nothing) Then _
        m_SelectedButton.Pushed = False

    ' Push the new button.
    m_SelectedButton = e.Button
    m_SelectedButton.Pushed = True

    lblTool.Text = m_SelectedButton.ToolTipText
End Sub