How to: Create and Modify the Control's Large Image List

  • 2 minutes to read

The following sample code creates and modifies an image list that will serve as the source of large images for the control. The modified component is assigned to the NavBarControl.LargeImages property. The NavElement.LargeImageIndex property is used to assign images to items and a group. The NavBarGroup.UseSmallImage and NavBarGroup.GroupStyle properties are set to false to enable displaying large images.

The image below displays the control's look & feel before and after code execution:

Images - LargeIndex

using DevExpress.XtraNavBar;

// adjusting an image list
ImageList largeImageSource = new ImageList();
largeImageSource.ImageSize = new Size(32, 32);
largeImageSource.Images.Add(Image.FromFile("E:\\Images\\Icons\\MSHelpLarge.bmp"));
largeImageSource.Images.Add(Image.FromFile("E:\\Images\\Icons\\IndexLarge.bmp"));
largeImageSource.Images.Add(Image.FromFile("E:\\Images\\Icons\\BookClosedLarge.bmp"));

// setting the image list as the source of large images
navBarControl1.LargeImages = largeImageSource;

// assigning a large image to a group caption
NavBarGroup currGroup = navBarControl1.Groups[1];
currGroup.LargeImageIndex = 0;
currGroup.UseSmallImage = false;

// assigning large images to items
currGroup.ItemLinks[0].Item.LargeImageIndex = 1;
currGroup.ItemLinks[1].Item.LargeImageIndex = 2;
currGroup.LinksUseSmallImage = false;