Library tutorials & articles
Toolbar Control
- Introduction
- Adding Buttons
- Using Images
- Seperators
- Running Code
- Toggling Buttons
- Enabling Buttons
Adding Buttons
First, add the toolbar control to a form. To do this, select the toolbar item
Then, simply 'draw' it onto the form, and it will automatically stick to the top edge of your form. If you don't want it at the top, you can change the controls Align property to make it appear at the bottom, left etc...
Usually, you won't need to add buttons at run-time, as you will know exactly what you want before your program starts, so for this tutorial, we will focus on adding buttons at design-time. To do this, right click on the toolbar you have just added and click Properties. The dialog that appears allows you to modify the appearance of the toolbar control and its buttons. Click the Buttons tab, and then click Insert Button.
You will notice that a blank button automatically appears on the toolbar in the form, and the text boxes in the Properties window are enabled. The Caption property specifies the text that appears at the bottom of the button. If you leave this blank, space will be left just for the icon. For the moment, enter the text 'Open' (without the quotes). The next box lets you specify a key that uniquely identifies the button. Fill this with 'Open' too. This is all you have to specify for a button, but the table below explains the other button properties you can set.
| Property | Description |
| Index | Displays the Index (position) of the button in the toolbar |
| ToolTipText | Sets the text that appears when the mouse hovers over the button |
| Style | Sets the button style. This will be explained later in the tutorial |
| Image | Specifies the image in the ImageList to be displayed. This is explained in the 'Using Images' section. |
| Tag | Allows you to store other data about the button you can use. The Toolbar control ignores this. |
| Visible | Specifies whether the button is visible or not |
| Enabled | Specifies whether the button is enabled or not |
| MixedState | Specifies if the button has a 3rd state (ie not down, but not up either. If you're not sure what I mean, try it!) |
Add a few more buttons for 'Save' and 'New' by clicking New Button again and filling out the values. You can move between the buttons in the property window by clicking the <> arrows next to the Index value. Once you are happy with the toolbar, click OK. Your form should now look something like this:
Related articles
Related discussion
-
Run-time error '91'
by crazyidane (0 replies)
-
Problem handling Redirects with MSXML2.XMLHTTP
by brandoncampbell (2 replies)
-
vbinputbox pauses code while it waits on response. How can I reproduce that?
by brandoncampbell (1 replies)
-
Sending SMS in VB 6
by sirobnole (6 replies)
-
Comboxbox listindex in ActiveX Control
by brandoncampbell (1 replies)
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
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.
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.
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.
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
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
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...
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
Private Sub RTBChange()
Toolbar1.Buttons("Bold").Value = Abs(RTB.SelBold)
End Sub
Private Sub Toolbar1ButtonClick(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
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
... see my new topic @ http://www.developerfusion.com/forums/topic.aspx?id=6283 regarding this
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
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
This thread is for discussions of Toolbar Control.