How to: Prevent Group Rows from being Expanded

  • 4 minutes to read

The following example shows how to customize whether a particular group row can be expanded.In this example, the 'Status: Invalidated' group row is prevented from being expanded, and the full expanding is disabled. To do this, the GroupRowExpanding event is handled, and the event parameter's Allow property is set to false when the RowHandle property returns the 'Status: Invalidated' row's handle, or an invalid handle (this happens when all group rows are about to be expanded).

View Example

using System.Windows;
using DevExpress.Xpf.Grid;
using DXExample.DemoData;

namespace DXGrid_PreventGroupRowsFromExpanding {
    public partial class Window1 : Window {
        public Window1() {
            gridControl1.ItemsSource = Invoice.GetData();
        private void gridControl1_GroupRowExpanding(object sender, RowAllowEventArgs e) {
            if ( e.Row == null ||
                ((Invoice)e.Row).Status == InvoiceStatus.Invalidated &&
                colStatus.GroupIndex != -1 )
                e.Allow = false;