Manual Items Creation

  • 2 minutes to read

In an unbound mode, the ASPxTrackBar control is not bound to any data source, and you can populate it with items manually.

Items can be manually created at design time via the Items Editor or directly in an aspx file.

At runtime, you can create items via the TrackBarItemCollection.Add or ListEditItemCollectionBase.AddRange methods.

Creating Items at Design-Time

You can use the Items Editor dialog to manually create ASPxTrackBar items at design time.

The Items Editor dialog allows you to add, delete and rearrange items, access and customize item settings. The dialog is shown in the image below.


When the OK button is clicked, the aspx code that adds the created items is generated. The code is listed below.

<dx:ASPxTrackBar ID="ASPxTrackBar1" runat="server" ScalePosition="Both" 
    PositionEnd="4" PositionStart="0" ValueType="System.String">
        <dx:TrackBarItem Text="Mon" ToolTip="Monday" Value="Monday"/>
        <dx:TrackBarItem Text="Tue" ToolTip="Tuesday" Value="Tuesday"/>
        <dx:TrackBarItem Text="Wed" ToolTip="Wednesday" Value="Wednesday"/>
        <dx:TrackBarItem Text="Thu" ToolTip="Thursday" Value="Thursday"/>
        <dx:TrackBarItem Text="Fri" ToolTip="Friday" Value="Friday"/>
        <dx:TrackBarItem Text="Sat" ToolTip="Saturday" Value="Saturday"/>
        <dx:TrackBarItem Text="Sun" ToolTip="Sunday" Value="Sunday"/>

You can create items directly in an aspx file, writing a similar code.

The following image shows the result.


Creating Items at Runtime

ASPxTrackBar allows you to create items with specified settings at runtime, using the TrackBarItemCollection.Add or ListEditItemCollectionBase.AddRange methods. You can create all the items at one time or create items dynamically on demand.

See the example.