Skip to main content

ListBoxSettings.ItemRowPrepared Property

Enables the settings of individual rows to be changed.

Namespace: DevExpress.Web.Mvc

Assembly: DevExpress.Web.Mvc5.v23.2.dll

NuGet Package: DevExpress.Web.Mvc5

Declaration

public EventHandler<ListBoxItemRowPreparedEventArgs> ItemRowPrepared { get; set; }

Property Value

Type Description
EventHandler<ListBoxItemRowPreparedEventArgs>

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

Remarks

Use the ItemRowPrepared event to change individual rows’ style settings (CssClass, Tooltip, control styles). The ItemRowPrepared event is raised for each row within the editor’s list.

The processed row is identified by the ListBoxItemRowPreparedEventArgs.Row 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