ToolBar.ImageList Property

Gets or sets the collection of images available to the toolbar button controls.

Namespace: System.Windows.Forms
Assembly: System.Windows.Forms (in

public ImageList ImageList { get; set; }
/** @property */
public ImageList get_ImageList ()

/** @property */
public void set_ImageList (ImageList value)

public function get ImageList () : ImageList

public function set ImageList (value : ImageList)

Not applicable.

Property Value

An ImageList that contains images available to the ToolBarButton controls. The default is a null reference (Nothing in Visual Basic).

If you create an ImageList and assign it to the ImageList property, you can assign an image from the collection to the ToolBarButton controls by assigning the image's index value to the ImageIndex property of the toolbar button.

The following code example creates a ToolBar control, sets some of its common properties, and adds it to a Form. Delegates are also added to the ButtonClick and ButtonDropDown events. This example requires that a ToolBar named toolBar1 and an ImageList named imageList1 have been declared.

private void AddToolBar()
   // Add a toolbar and set some of its properties.
   toolBar1 = new ToolBar();
   toolBar1.Appearance = System.Windows.Forms.ToolBarAppearance.Flat;
   toolBar1.BorderStyle = System.Windows.Forms.BorderStyle.None;
   toolBar1.ButtonSize = new System.Drawing.Size(24, 24);
   toolBar1.Divider = true;
   toolBar1.DropDownArrows = true;
   toolBar1.ImageList = this.imageList1;
   toolBar1.ShowToolTips = true;
   toolBar1.Size = new System.Drawing.Size(292, 25);
   toolBar1.TabIndex = 0;
   toolBar1.TextAlign = System.Windows.Forms.ToolBarTextAlign.Right;
   toolBar1.Wrappable = false;
   // Add handlers for the ButtonClick and ButtonDropDown events.
   toolBar1.ButtonDropDown += 
     new ToolBarButtonClickEventHandler(toolBar1_ButtonDropDown);
   toolBar1.ButtonClick += 
     new ToolBarButtonClickEventHandler(toolBar1_ButtonClicked);

   // Add the toolbar to the form.

private void AddToolBar()
    // Add a toolbar and set some of its properties.
    toolBar1 = new ToolBar();
    toolBar1.set_ButtonSize(new System.Drawing.Size(24, 24));
    toolBar1.set_Size(new System.Drawing.Size(292, 25));
    // Add handlers for the ButtonClick and ButtonDropDown events.
    toolBar1.add_ButtonDropDown(new ToolBarButtonClickEventHandler
    toolBar1.add_ButtonClick(new ToolBarButtonClickEventHandler
    // Add the toolbar to the form.
} //AddToolBar

Windows 98, Windows Server 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0, 2.0, 1.1, 1.0

.NET Compact Framework

Supported in: 2.0, 1.0

Community Additions