ASPxClientComboBox.AddItem(text) Method
Adds a new item to the end of the control’s items collection.
Declaration
AddItem(
text: string | string[],
value?: any,
imageUrl?: string
): number
Parameters
Name | Type | Description |
---|---|---|
text | string | string[] | Specifies the item’s text. |
value | any | An object that represents the item’s associated value. |
imageUrl | string | A string value specifying the path to the image displayed by the item. |
Returns
Type | Description |
---|---|
number | An integer value representing the position at which a new item was added. |
Remarks
Use the AddItem method to add a new item to the end of the collection, or the ASPxClientComboBox.InsertItem method - to add a new item at the specified index of the collection.
Note
The AddItem method is in effect if the control’s client API is enabled using one of the following methods:
- Set the control’s EnableClientSideAPI property to true.
- Set the control’s EnableCallbackMode property to true.
- Define the control’s ClientInstanceName property.
- Handle any control’s client-side event (available via the control’s ClientSideEvents property).
The ASPxClientComboBox.GetItem method allows you to obtain an item with the specified index. You can remove an item from the collection by the ASPxClientComboBox.RemoveItem method.
Note that the editor does not display values of hidden columns (WebColumnBase.Visible). So, you cannot use the AddItem method to set a hidden column’s value;
If you add an item with the specified image to the editor’s Items collection where no items have images yet, it is necessary to explicitly define the editor’s ItemImage.Width and ItemImage.Height properties. Otherwise, the editor does not display the newly added item’s image.
Note
Set the EnableSynchronization property to true to synchronize client item manipulation with the server Items collection.
Examples
- AddItem(String[] texts)
<dx:ASPxComboBox ID="ASPxComboBox1" ClientInstanceName="cb" runat="server" ValueType="System.String" Theme="Office365">
<Columns>
<dx:ListBoxColumn />
<dx:ListBoxColumn />
<dx:ListBoxColumn />
</Columns>
</dx:ASPxComboBox>
- AddItem(string text)
<dx:ASPxComboBox ID="ASPxComboBox1" ClientInstanceName="cb" runat="server" ValueType="System.String" Theme="Office365">
</dx:ASPxComboBox>
- ASPxClientComboBox.AddItem(String[], Object)
<dx:ASPxComboBox ID="ASPxComboBox1" ClientInstanceName="cb" runat="server" ValueType="System.String" Theme="Office365">
<Columns>
<dx:ListBoxColumn />
<dx:ListBoxColumn />
<dx:ListBoxColumn />
</Columns>
</dx:ASPxComboBox>
- ASPxClientComboBox.AddItem(String, Object)
<dx:ASPxComboBox ID="ASPxComboBox1" ClientInstanceName="cb" runat="server" ValueType="System.String" Theme="Office365">
</dx:ASPxComboBox>
- ASPxClientComboBox.AddItem(String[], Object, String)
<dx:ASPxComboBox ID="ASPxComboBox1" ClientInstanceName="cb" runat="server" ValueType="System.String" Theme="Office365">
<Columns>
<dx:ListBoxColumn />
<dx:ListBoxColumn />
<dx:ListBoxColumn />
</Columns>
</dx:ASPxComboBox>
- ASPxClientComboBox.AddItem(String, Object, String)
<dx:ASPxComboBox ID="ASPxComboBox1" ClientInstanceName="cb" runat="server" ValueType="System.String" Theme="Office365">
</dx:ASPxComboBox>
Online Example
How to add items to a multi-column ASPxComboBox on the client side