Files
docs-desktop/dotnet-desktop-guide/framework/winforms/controls/how-to-define-an-icon-for-a-toolbar-button-using-the-designer.md
T
Andy De George c0ba284473 Initial winforms content migrated (#18)
* Merge winforms framework content to working branch (#14)

* Breadcrumb / TOC / Move net5 to net folder (#15)

* change path from net5 to net

* Mess with bread/toc

* Mess with bread/toc

* Mess with bread/toc

* Mess with bread/toc

* Mess with bread/toc

* Mess with bread/toc

* Mess with bread/toc

* Mess with bread/toc

* Mess with bread/toc

* Mess with bread/toc

* Mess with bread/toc

* Mess with bread/toc

* Mess with bread/toc

* Mess with bread/toc

* Add .net 5 winforms placeholder article (#16)

* added some metadata and adjusted net5 placeholder

* corrections

* corrections

* corrections

* Test1

* Swapping landing page vs concept

* fix links

* Fix links

* Fix desc
2020-09-01 16:26:21 -07:00

3.1 KiB

title, ms.date, helpviewer_keywords, ms.assetid
title ms.date helpviewer_keywords ms.assetid
How to: Define an Icon for a ToolBar Button Using the Designer 03/30/2017
toolbars [Windows Forms], adding icons to buttons
examples [Windows Forms], toolbars
images [Windows Forms], toolbar buttons
buttons [Windows Forms], images
icons [Windows Forms], toolbar buttons
ToolBar control [Windows Forms], adding icons to buttons
d848f38e-67f2-49d4-8e88-01c845c06c02

How to: Define an Icon for a ToolBar Button Using the Designer

Note

The xref:System.Windows.Forms.ToolStrip control replaces and adds functionality to the xref:System.Windows.Forms.ToolBar control; however, the xref:System.Windows.Forms.ToolBar control is retained for both backward compatibility and future use, if you choose.

xref:System.Windows.Forms.ToolBar buttons are able to display icons within them for easy identification by users. This is achieved through adding images to the xref:System.Windows.Forms.ImageList component and associating it with the xref:System.Windows.Forms.ToolBar control.

The following procedure requires a Windows Application project with a form containing a xref:System.Windows.Forms.ToolBar control and an xref:System.Windows.Forms.ImageList component. For information about setting up such a project, see How to: Create a Windows Forms application project and How to: Add Controls to Windows Forms.

To set an icon for a toolbar button at design time

  1. Add images to the xref:System.Windows.Forms.ImageList component. For more information, see How to: Add or Remove ImageList Images with the Designer.

  2. Select the xref:System.Windows.Forms.ToolBar control on your form.

  3. In the Properties window, set the xref:System.Windows.Forms.ToolBar control's xref:System.Windows.Forms.ToolBar.ImageList%2A property to the xref:System.Windows.Forms.ImageList component.

  4. Click the xref:System.Windows.Forms.ToolBar control's xref:System.Windows.Forms.ToolBar.Buttons%2A property to select it, and click the ellipsis (The Ellipsis button (...) in the Properties window of Visual Studio.) button to open the ToolBarButton Collection Editor.

  5. Use the Add button to add buttons to the xref:System.Windows.Forms.ToolBar control.

  6. In the Properties window that appears in the pane on the right side of the ToolBarButton Collection Editor, set the xref:System.Windows.Forms.ToolBarButton.ImageIndex%2A property of each toolbar button to one of the values in the list, which is drawn from the images you added to the xref:System.Windows.Forms.ImageList component.

See also