Library tutorials & articles

Toolbar Control

Using Images

So far the toolbar doesn't really look like a toolbar at all, because it doesn't have any pictures. You can add these using an ImageList control. First, add an ImageList control to the form, and add 3 icons to it (you can use the Open, Save and New bitmap files in the CommonGraphicsBitmapsTlBr_W95 folder where VB is installed, or download the Editing icons from our Icon Library), and set their keys to Open, Save and New too.

Now we have an image list with some images in it, we need to associate it with the Toolbar. To do this, return to the Toolbar property window, and in the ImageList drop down, select the name of the ImageList control. Now, go to the Buttons tab. You will notice that the Image box is now enabled. In that box you can either enter the Index or the Key of the image you want displayed. It is usually a good idea to use the Key because that is more meaningful than just a miscellaneous number. So, for the Open button, enter 'Open' in the Image box (because Open is the key of the icon we want to use in the ImageList). Then, do the same for the other buttons. That's all there is too it.

Now, you're toolbar will be looking much more like a toolbar!

You might, at this stage decide that you don't want the text displayed below the icon. If this is the case, simply set the Caption property to nothing for the 3 buttons.

Comments

  1. 19 Jan 2007 at 19:55

    Hi,

    I am trying to create keyboard shortcuts for toolbar buttons in VB.NET. Eg. For a button titled Manual I am setting the Text property to '&Manual'. In run mode when I press Alt+M, the underline of Manual becomes visible and nothing happens - the click event of the button is never fired. What am I missing?

    Thanks

  2. 10 Jul 2006 at 21:13

    How would i resize the button if i had the text align to the right.

    for some reason when i try to change the width it switches right back to the width of whichever button that would have the longest amont of characters.

     

  3. 05 Apr 2005 at 00:17

    Hi!
    I am using a imagelist with a toolbar and when I am trying to disable an image in the tool bar the image is getting completely faded (no image is being displayed but simply a complete gray section is being displayed). However I want the image to be displayed in a shaded mode (similar to a general disabled image). Is there anything I need to do this? I appreciate your quick help.
    Thanks in advance.


    Regards,
    Satish.

  4. 03 Oct 2003 at 01:20

    FYI, if you want to do your own Toolbar graphics I have a freeware toolbar paint program that allows you to create imagelists quickly and easily. You can import icons, individual images from other imagelists or even toolbars directly from exe's or dll's. It is a full paint package as well. Written entirely in assembler it requires no runtimes or support files and weighs in at under 40K. Check it out at:


    http://donkey.visualassembler.com/


    PS sorry for this shameless plug but I was googling for something and came across your board.

  5. 05 Sep 2003 at 03:36

    HI all


    this is my code en c# ,
    I have six button but they no working .


    private void toolBar1_ButtonClick(object sender, System.Windows.Forms.ToolBarButtonClickEventArgs e)
    {


    }


    who can help to put them to work,


    thanks you

  6. 18 May 2003 at 01:26

    i've set up the toolbar.....but how to code the buttons so that they will serve their purposes. eg: coding for save, cut, paste, undo , redo, etc....


    thanks

  7. 03 Mar 2003 at 04:09

    from last 15 days i was searching the toolbar controls ie how to change the images on the buttons of inserted toolbar because i am a new user for vb at last i get here and that to a great satifactory leval thank you very much...

  8. 27 Aug 2002 at 08:05
    Fr From rajah,

     The code to enabled and disabled the toolbars button is simply superb,i have searched the entire web but this is the only web where i found this simple code.

    Thanks  You Very Much
  9. 19 Jul 2002 at 11:47

    Private Sub RTBChange()
       Toolbar1.Buttons("Bold").Value = Abs(RTB.SelBold)
    End Sub
    Private Sub Toolbar1
    ButtonClick(ByVal Button As MSComctlLib.Button)
       Select Case Button.Key
       Case "Bold"
           If RTB.SelBold = True Then
               RTB.SelBold = False
           Else
               RTB.SelBold = True
           End If
           RTB_Change


    End Sub

  10. 11 Jul 2002 at 09:01

    r u sure there is a 'selected' property for toolbar button. i am unable to find it. infact there is no "buttons" thing . r u talking abt IE webcontrols or something else?


    sandeep

  11. 12 May 2002 at 15:20

    ... see my new topic @ http://www.developerfusion.com/forums/topic.aspx?id=6283 regarding this

  12. 04 Apr 2002 at 08:52
    James Crowley has mentioned :
    Toolbar1.Buttons("Underline").Selected = Abs(RichTextBox1.SelUnderline)

    With the release of Visual Studio .NET, this topic is no longer being updated.
    SelBold, SelItalic, SelStrikethru, SelUnderline Properties.

    So if u try to use it will give u error saying , not a memeber of richtextbox.

    Pls wait till its updated.....

    Arvind
  13. 09 Jan 2002 at 06:15

    I am trying to do the same thing. I have inserted both control in my project. And then insert them on my dialog. I do the same steps as I do in VB to set the properties.


    But when I got to the properties of toolbar control I cant see the imaglist ID there, it is on ly <NONE>. How can I make my image list control to appear in that list??


    Any idea?


    Help will be appreciated.


    Thanxs

  14. 01 Jan 1999 at 00:00

    This thread is for discussions of Toolbar Control.

Leave a comment

Sign in or Join us (it's free).

James Crowley James first started this website when learning Visual Basic back in 1999 whilst studying his GCSEs. The site grew steadily over the years while being run as a hobby - to a regular monthly audience ...
AddThis

Related discussion

Related podcasts

  • Christian Beauclair

    14 mai 2008 (�mission #0074) ::.Christian Beauclair: Stratégies de migration VB6 vers .NET Nous discutons avec Christian Beauclair des stratégies de migration VB6 vers .NET. Entre autres, nous discutons comment utiliser le "VB 6 Code Advisor" et le "Interop Forms Toolkit" pour ajouter la puiss...

Want to stay in touch with what's going on? Follow us on twitter!