Skip to main content

NavigatorButtonCollectionBase.Item[Int32] Property

Gets the button at the specified index.

Namespace: DevExpress.XtraEditors

Assembly: DevExpress.XtraEditors.v24.1.dll

NuGet Package: DevExpress.Win.Navigation

Declaration

public NavigatorButton this[int index] { get; }

Parameters

Name Type Description
index Int32

An integer value representing the button’s zero-based index. If negative or exceeds the maximum available index, an exception is raised.

Property Value

Type Description
NavigatorButton

A NavigatorButton object representing the button at the specified position within the collection.

Remarks

Use the Item property to access individual buttons using index notation. This property returns an NavigatorButton object and its properties can be used to customize a button’s settings. For example, you can specify the index of the image to be displayed on the button via the NavigatorButtonBase.ImageIndex property.

Example

The following code shows how to create a new DataNavigator control, bind it to a data source and specify custom images for the control’s buttons at runtime. The custom images are stored in an ImageCollection object.

DataNavigator ctor

using DevExpress.XtraEditors;

private void CreateDataNavigator() {
    // Create a new DataNavigator control
    DataNavigator dataNavigator = new DataNavigator();
    Controls.Add(dataNavigator);
    dataNavigator.Height = 40;
    dataNavigator.Dock = DockStyle.Bottom;
    // Bind to a data source
    dataNavigator.DataSource = productsBindingSource;
    // Specify the ImageCollection that stores custom images for the DataNavigator's buttons
    dataNavigator.Buttons.ImageList = imageCollection1;
    for (int i = 0; i < dataNavigator.Buttons.ButtonCollection.Count; i++) {
        dataNavigator.Buttons.ButtonCollection[i].ImageIndex = i;
    }
    dataNavigator.ShowToolTips = true;
}
See Also