Back to Devexpress

ASPxCardView.CardLayoutCreated Event

aspnet-devexpress-dot-web-dot-aspxcardview-d14a6d1d.md

latest3.6 KB
Original Source

ASPxCardView.CardLayoutCreated Event

The event occurs when the card layout is created.

Namespace : DevExpress.Web

Assembly : DevExpress.Web.v25.2.dll

NuGet Package : DevExpress.Web

Declaration

csharp
public event ASPxCardViewCardLayoutCreatedEventHandler CardLayoutCreated
vb
Public Event CardLayoutCreated As ASPxCardViewCardLayoutCreatedEventHandler

Event Data

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

PropertyDescription
IsEditingCardGets whether the card is in edit mode.
PropertiesContains settings related to the FormLayout used in the processed card.
VisibleIndexGets the visible index of the processed card.

The event data class exposes the following methods:

MethodDescription
FindLayoutItemByColumn(String)Returns a layout item that belongs to the specified column.
FindLayoutItemOrGroup(String)Returns a layout item or group object with the specified name.

Remarks

The card view raises the CardLayoutCreated event for each data card when the corresponding card layout is created. You can handle this event to change card styles or settings based on cell values.

In addition to the event argument properties, you can use the FindLayoutItemByColumn(String) and FindLayoutItemOrGroup(String) methods to access and modify layout items or groups.

The following example illustrates how to use the FindLayoutItemByColumn(String) method to find a card’s layout items that belong to the specified columns. It also allows you to change these items’ visibility and column-span if the card is in edit mode.

csharp
protected void ASPxCardView1_CardLayoutCreated(object sender, ASPxCardViewCardLayoutCreatedEventArgs e) {
    // Applies the card layout to the Edit Form only
    if(e.IsEditingCard) {
        ASPxCardView cardView = sender as ASPxCardView;
        if(cardView.IsNewCardEditing) {
            LayoutItem itemOrderID = e.FindLayoutItemByColumn(cardView.KeyFieldName);
            itemOrderID.ClientVisible = false;
            LayoutItem itemProductName = e.FindLayoutItemByColumn("ProductName");
            itemProductName.ColumnSpan = 2;
        }
    }
}

See Also

ASPxCardView Class

ASPxCardView Members

DevExpress.Web Namespace