The List Bar Control

Introduction

The list bar, also known as Outlook bar, is a control which is found in many Windows applications. Its appearance varies depending on the application, but generally it looks something like this:

Usage

The object model of this control is illustrated in the diagram below.

To create a simple application containing a list bar, create a new Windows Forms application then follow the steps below.

  1. Add the NETXP.Controls.Bars.dll assembly to your toolbox if necessary.
  2. Drag and drop the ListBar control to your form.
  3. Set the ListBar's dock style to Left.
  4. At the bottom of the property window you will see a link: Add Group. Click that link to add a new group to the list bar.
  5. The new group is now selected. Change its caption by setting the Caption property to "Outlook Shortcuts", without the quotes.
  6. For each group you can specify one of three display styles (for the items contained in that group): TextUnderneath, TextRight, and NoText. The first two correspond to the Outlook bar and VS.NET toolbox controls, respectively. Specify the TextUnderneath style for the View property.
  7. Edit this group's item collection by selecting the Items property and clicking the [...] button. Click Add to add a new item.
  8. Set the Caption of the item to "Outlook Today" (no quotes). Specify any 32x32 image for this item.
  9. Repeat step #8 for the Inbox item.
  10. Click OK to close the collection editor. Select the ListBar again, and click Add Group. Set the group's Caption property to "Other Shortcuts" without the quotes. Set its View property to TextRight.
  11. Add three new items to Other Shortcuts, each having its own caption and 16x16 image.
  12. Close the form designer and save the project.

This simple tutorial has now taught you the basics of using the list bar control in NetXP.

Handling Mouse Events

To handle mouse events per-item you should hook up to the control's MouseDown or MouseUp event, then inside the event handler use the ListBar's HitTest method with the given point to find the item under the mouse. The return value of HitTest is an IMouseHandler object, so you should convert it to a ListBarItem accordingly.