Skip to main content
A newer version of this page is available. .
Tab

ASPxListBox.ItemTextCellPrepared Event

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

Namespace: DevExpress.Web

Assembly: DevExpress.Web.v18.2.dll

Declaration

public event EventHandler<ListBoxItemTextCellPreparedEventArgs> ItemTextCellPrepared

Event Data

The ItemTextCellPrepared event's data class is ListBoxItemTextCellPreparedEventArgs. The following properties provide information specific to this event:

Property Description
Column Gets the column that owns a cell that is about to be processed.
Item Gets an item object related to the event.
TextCell Gets the currently processed cell of the editor.

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 list box items.

ASPxListBox-ItemAppearanceCustomization

string GetItemTooltip(ListEditItem item)
{
    return string.Format("Country: {0}\r\nCity: {1} \r\nAddress: {2}",
        item.GetFieldValue("Country"), item.GetFieldValue("City"), item.GetFieldValue("Address"));
}
protected void ASPxListBox1_ItemTextCellPrepared(object sender, DevExpress.Web.ListBoxItemTextCellPreparedEventArgs 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";
}
protected void ASPxListBox1_ItemRowPrepared(object sender, DevExpress.Web.ListBoxItemRowPreparedEventArgs e)
{
    e.Row.ToolTip = GetItemTooltip(e.Item);
}
See Also