Skip to main content

ListBoxSettings.ItemTextCellPrepared Property

Occurs on the server side before a text cell has been rendered.

Namespace: DevExpress.Web.Mvc

Assembly: DevExpress.Web.Mvc5.v24.1.dll

NuGet Package: DevExpress.Web.Mvc5

Declaration

public EventHandler<ListBoxItemTextCellPreparedEventArgs> ItemTextCellPrepared { get; set; }

Property Value

Type Description
EventHandler<ListBoxItemTextCellPreparedEventArgs>

A EventHandler<TEventArgs><ListBoxItemTextCellPreparedEventArgs,> delegate method allowing you to implement custom processing.

Remarks

Write a ItemTextCellPrepared event handler to customize the cell appearance (CssClass, Tooltip, control styles) before it is rendered. To customize the cell’s appearance, use the ListBoxItemTextCellPreparedEventArgs.TextCell, ListBoxItemTextCellPreparedEventArgs.Column and ListBoxItemTextCellPreparedEventArgs.Item properties.

The editor’s content is customized using the ASPxListBox.ItemTemplate property.

Example

The following example illustrates how to customize the appearance of combo box items.

ASPxListBox-ItemAppearanceCustomization

@Html.DevExpress().ListBox(
    settings => {
        settings.Name = "customersListBox";
        settings.CallbackRouteValues = new { Controller = "Editors", Action = "ListBoxWithItemCustomizationPartial" };
        // ...

        settings.ItemTextCellPrepared += (s, e) => {
            if(e.Column.FieldName == "ContactName") {
                string contactTitle = e.Item.GetFieldValue("ContactTitle").ToString();
                if(contactTitle == "Owner") {
                    e.TextCell.CssClass += " owner";
                    e.TextCell.ToolTip = "Owner";
                }
            }
            if(e.Column.FieldName == "Phone")
                e.TextCell.CssClass += " phone";
        };
        settings.ItemRowPrepared += (s, e) => {
            ListEditItem item = e.Item;
            e.Row.ToolTip = string.Format("Country: {0}\r\nCity: {1} \r\nAddress: {2}",
                item.GetFieldValue("Country"), item.GetFieldValue("City"), item.GetFieldValue("Address"));
        };
        // ...

    }
).BindList(ViewData["Customers"]).GetHtml()
See Also