Visual Basic

What Is Toolbar In Visual Basic

A toolbar in a Visual Basic application is a row or column of buttons and other controls that gives users quick access to common commands, such as Save, Print or Clear. In a Windows Forms application, you can build one with a ToolStrip control and.

Which licences fit your PC setup?

Prices are an AUD snapshot, not a live quote. Confirm variant and total on the listing.

What a toolbar does in Visual Basic

A toolbar puts frequently used actions within easy reach. For example, a text editor might offer Open, Save and Print buttons, while a records application might provide New, Find and Refresh. These buttons often offer shortcuts to commands that are also available through menus.

The toolbar provides the interface; your code supplies the behaviour. Adding a Save icon does not automatically save a document. You must connect the button to the appropriate operation and handle any conditions that affect it, such as an invalid file location.

There are two different contexts to recognise when following a tutorial:

  • The development environment's toolbars contain commands used while writing, building or debugging your project.
  • An application's toolbar belongs to the program you are creating and contains commands for its users.

Customising the development environment does not add a toolbar to your application's window. The steps below concern a toolbar on a Windows Form. For related beginner topics, browse the Visual Basic guides.

Which control should you use?

For a Visual Basic Windows Forms project, use ToolStrip to create a toolbar. Microsoft describes it as the replacement for the earlier Windows Forms ToolBar control, with support for buttons, drop-down items and flexible layouts. Its ToolStrip overview explains the available features.

Check which project type a tutorial uses before copying its instructions. Visual Basic is the programming language; the user interface framework determines which controls and design tools are available. Instructions for classic Visual Basic projects or another interface framework will not necessarily apply to Windows Forms.

Useful toolbar items

  • ToolStripButton provides a clickable command, such as Save or Refresh.
  • ToolStripDropDownButton opens a list of related choices.
  • ToolStripSeparator visually divides groups of commands.
  • ToolStripLabel supplies a short label within the strip.
  • ToolStripTextBox or ToolStripComboBox accepts text or a selection, such as a search term or formatting choice.

Start with the items your users need most often. A small toolbar with recognisable commands is easier to understand than one containing every available operation.

How to add a toolbar to a Windows Form

  1. Open your Windows Forms project and display the form in the designer.
  2. Find ToolStrip in the Toolbox and add it to the form. Set its Dock property if you want it attached to a particular edge.
  3. Add the required items using the ToolStrip designer. For a simple practice form, begin with a ToolStripButton labelled Clear.
  4. Give the button a descriptive Name, such as ClearToolStripButton. Set its Text and ToolTipText so its purpose is clear, and choose an appropriate DisplayStyle for text, an image or both.
  5. Create a handler for the button's Click event. In the designer, double-clicking a standard ToolStripButton creates its default Click handler.
  6. Add the code for the command, then run the application and check the result.

A useful first check is whether the toolbar appears where intended and whether clicking its button performs the expected action. Also resize the window to see whether the commands remain accessible.

Connect toolbar commands to your form

Toolbar buttons usually work with other controls. A Clear command might empty the input fields, a Find command might search the displayed records, and a formatting button might act on selected text.

If both a menu item and a toolbar button perform the same operation, put that operation in a shared procedure. Each Click handler can call it. This keeps validation and behaviour consistent when you change the command later.

For a practice Clear command, first decide which fields should reset and whether any defaults should be restored. The guide on coding a Clear button in Visual Basic provides a related exercise. Connect the reset operation to your toolbar button once it works on the form.

Show whether a command is available or selected

Availability and selection mean different things. A Delete command may be unavailable because no record is selected. A formatting toggle may be available and checked because the selected text uses that format.

Use a button's Enabled property to control whether the user can activate it. Update that property when the relevant application state changes. For example, enable a selection-dependent command when a suitable item becomes selected.

For a toggle, ToolStripButton supports CheckOnClick and Checked. Microsoft demonstrates this behaviour in its toggle button instructions. The checked appearance still needs to correspond to the actual setting in your application.

If an option also appears as a checkbox elsewhere on the form, keep both controls in agreement. Practising checkbox handling in Visual Basic can help you understand how an interface reflects an on/off setting.

Make the toolbar easy to understand

Group related commands and use separators sparingly. Give unfamiliar commands visible text rather than relying entirely on an icon. Tooltips can explain a button, but users should not have to hover over every item to discover its purpose.

Keep toolbar behaviour consistent with the rest of the application. If a command is unavailable in the menu, check whether its toolbar equivalent should also be disabled. If a command changes a setting, update every control that displays that setting.

User customisation is something you implement deliberately. Adding a toolbar does not automatically give users a complete interface for choosing buttons, rearranging them and saving their preferences.

Add a ToolStrip with one clearly labelled Clear button to a practice form, connect its Click handler, and check that it resets only the fields you intended.

Other editions for separate workloads

Other editions for separate workloads; prices in AUD, confirm the total on the listing.

How to check this worked

  1. Open Settings, System, Activation and confirm the edition shown.
  2. Enter the key and run activation; expect a green tick within a minute.
  3. Reboot and re-check activation survives the restart.

FAQ

What else should you know before buying?

What do I need before starting?
Read the requirements and confirm the edition first; the steps assume the machine is compatible.
How do I know the licence is genuine?
Activate on Microsoft's servers and check Settings, System, Activation. A working activation is the test.
Is this a subscription?
Keys sold here are one-time lifetime licences. Microsoft 365 plans are billed by Microsoft instead.
What if the key fails?
Email hi@ms.codes with the order number and a screenshot. Replacement or refund applies within 30 days.

Check who prepared and reviewed this guide

Written by
MS.Codes editorial
Reviewed by
Support team

Last verified: (source review; see test status above).

Recent Post