windowsforms-devexpress-dot-xtragrid-dot-views-dot-layout-e2192e0b.md
Identifies card field settings that can be modified via the LayoutView.CustomCardLayout event.
Namespace : DevExpress.XtraGrid.Views.Layout
Assembly : DevExpress.XtraGrid.v25.2.dll
NuGet Packages : DevExpress.Win.Grid, DevExpress.Win.Navigation
public enum LayoutItemDifferenceType
Public Enum LayoutItemDifferenceType
| Name | Description |
|---|---|
SelectedTabIndex |
Identifies the selected page index. The value for this setting must be of the Integer type. 0 corresponds to the first tab, 1 corresponds to the second tab, etc.
|
| GroupExpanded |
Identifies the group expansion state. A value for this setting must be of the Boolean type, where true indicates that the group is expanded and false indicates the group is collapsed.
|
| ItemVisibility |
Identifies the item’s visibility. A value for this setting must be of the Boolean type, where true indicates that the item is visible and false indicates that the item is hidden.
|
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:
using DevExpress.XtraGrid.Views.Layout.Events;
using DevExpress.XtraLayout;
// Indicates whether to display the Photo field in cards.
bool showPhoto = true;
void layoutView1_CustomCardLayout(object sender, LayoutViewCustomCardLayoutEventArgs e) {
// The name of the LayoutViewField object representing the Photo card field.
string colPhotoFieldName = layoutView1.Columns["Photo"].LayoutViewField.Name;
// The name of the Contact Info group.
string groupContactInfoName = "contactInfoGroup";
// Show the ContactInfo group only in the focused card
e.CardDifferences.AddItemDifference(groupContactInfoName,
LayoutItemDifferenceType.ItemVisibility, (layoutView1.FocusedRowHandle == e.RowHandle));
// Display the Photo field if the corresponding flag is set.
e.CardDifferences.AddItemDifference(colPhotoFieldName,
LayoutItemDifferenceType.ItemVisibility, showPhoto);
}
Imports DevExpress.XtraGrid.Views.Layout.Events
Imports DevExpress.XtraLayout
' Indicates whether to display the Photo field in cards.
Dim showPhoto As Boolean = True
Private Sub layoutView1_CustomCardLayout(ByVal sender As Object, _
ByVal e As LayoutViewCustomCardLayoutEventArgs)
' The name of the LayoutViewField object representing the Photo card field.
Dim colPhotoFieldName As String = layoutView1.Columns("Photo").LayoutViewField.Name
' The name of the Contact Info group.
Dim groupContactInfoName As String = "contactInfoGroup"
' Show the ContactInfo group only in the focused card
e.CardDifferences.AddItemDifference(groupContactInfoName, _
LayoutItemDifferenceType.ItemVisibility, (layoutView1.FocusedRowHandle = e.RowHandle))
' Display the Photo field if the corresponding flag is set.
e.CardDifferences.AddItemDifference(colPhotoFieldName, _
LayoutItemDifferenceType.ItemVisibility, showPhoto)
End Sub
See Also