The LayoutView.CustomCardLayout event can be used to dynamically customize the layout of fields (layout items) within a card in a LayoutView. To change the layout, you need to call the LayoutViewCardDifferences.AddItemDifference method, which creates a difference record identifying how a card field's settings differ from the default settings. The method's parameters identify the card field affected, the setting to be changed and the value for the setting. The settings that may be changed are enumerated by the LayoutItemDifferenceType type.
To get all difference records for a specific card field, use the LayoutViewCardDifferences.Item indexer. It returns the object of the LayoutItemDifferences type.

Example
The following example shows how to customize the layout of fields in cards via the LayoutView.CustomCardLayout event.
A card in the example contains a Photo field and a Contact Info group. In the event, the Photo field is only displayed in cards if a showPhoto flag is set. The Contact Info group is only displayed in the focused card; in other cards it's hidden.
The result is shown below:

C# |
using DevExpress.XtraGrid.Views.Layout.Events;
using DevExpress.XtraLayout;
bool showPhoto = true;
void layoutView1_CustomCardLayout(object sender, LayoutViewCustomCardLayoutEventArgs e) {
string colPhotoFieldName = layoutView1.Columns["Photo"].LayoutViewField.Name;
string groupContactInfoName = "contactInfoGroup";
e.CardDifferences.AddItemDifference(groupContactInfoName,
LayoutItemDifferenceType.ItemVisibility, (layoutView1.FocusedRowHandle == e.RowHandle));
e.CardDifferences.AddItemDifference(colPhotoFieldName,
LayoutItemDifferenceType.ItemVisibility, showPhoto);
}
|
VB |
Imports DevExpress.XtraGrid.Views.Layout.Events
Imports DevExpress.XtraLayout
Dim showPhoto As Boolean = True
Private Sub layoutView1_CustomCardLayout(ByVal sender As Object, _
ByVal e As LayoutViewCustomCardLayoutEventArgs)
Dim colPhotoFieldName As String = layoutView1.Columns("Photo").LayoutViewField.Name
Dim groupContactInfoName As String = "contactInfoGroup"
e.CardDifferences.AddItemDifference(groupContactInfoName, _
LayoutItemDifferenceType.ItemVisibility, (layoutView1.FocusedRowHandle = e.RowHandle))
e.CardDifferences.AddItemDifference(colPhotoFieldName, _
LayoutItemDifferenceType.ItemVisibility, showPhoto)
End Sub
|
System.Object
LayoutItemDifferences