Skip to main content

ASPxClientListBox.AddItemTextCellCssClass(itemIndex, textCellIndex, className) Method

Sets the CSS class for a list box item’s text cell specified by its index.

#Declaration

TypeScript
AddItemTextCellCssClass(
    itemIndex: number,
    textCellIndex: number,
    className: string
): void

#Parameters

Name Type Description
itemIndex number

The item’s index.

textCellIndex number

The index of the item’s text cell.

className string

A string value specifying the CSS class name.

#Remarks

Use the AddItemTextCellCssClass property to specify the CSS class for the item’s text cell of the editor on the client side.

#Example

This example illustrates how to customize the appearance of columns in a list box.

<head runat="server">
    <title></title>
   <style type="text/css">
        .class1 {
            color: #006100;
            background-color: #C6EFCE;
            font-weight: bold;
        }
        .class2 {
            color: brown;
            background-color: azure;
            font-weight: bold;
        }
    </style>
</head>

<body>
    <form id="form1" runat="server">
    <div>
        <dx:ASPxListBox ID="ASPxListBox1" ClientInstanceName="clientListBox" runat="server" DataSourceID="SqlDataSource1">
            <Columns>
                <dx:ListBoxColumn FieldName="ContactName" />
                <dx:ListBoxColumn FieldName="CompanyName" />
                <dx:ListBoxColumn FieldName="Phone" />
            </Columns>
            <ClientSideEvents Init="function(s, e) {
                for (i = 0 ; i < clientListBox.GetItemCount(); i++){
                    clientListBox.AddItemTextCellCssClass(i,1, 'class1');
                    clientListBox.AddItemTextCellCssClass(i,2, 'class2');
                }
}" />
        </dx:ASPxListBox>
        <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="Provider=Microsoft.Jet.OLEDB.4.0;
Data Source=|DataDirectory|\nwind.mdb;Persist Security Info=True" ProviderName="System.Data.OleDb" 
SelectCommand="SELECT [CompanyName], [ContactName], [ContactTitle], [Address], [City], [Region], [Country], [Phone] FROM [Customers]"></asp:SqlDataSource>
    </div>        
    </form>
</body>
See Also