Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
655
Don't allow change groups in a Wingrid
posted

I have a grid like you see in the image and would like the user couldn't change or move the groupings.

I've tried this.

With ultragrid1
.BeginUpdate()
.DisplayLayout.Override.AllowGroupMoving = AllowGroupMoving.NotAllowed .DisplayLayout.Override.AllowGroupSwapping = AllowGroupSwapping.NotAllowed .DisplayLayout.Bands(0).Override.AllowGroupMoving = AllowGroupMoving.NotAllowed .DisplayLayout.Bands(0).Override.AllowGroupSwapping = AllowGroupSwapping.NotAllowed
.EndUpdate()
End With


But I still adding and swapping groups.


I have already tried wiht BerforeGroupPosChanded event, but this event don't fires when I do drag & drop columns in the GroupBy Box

I'm using NedAdvange 11.2 version


  • 469350
    Verified Answer
    Offline posted

    Hi, 

    There are two kinds of grouping in the grid. One is OutlookGroupBy, which you are using in the screen shot here. The other refers to groups of columns. The properties you are setting here all apply to the grouping of columns, so that's why it's having no effect - it has nothing to do with OutlookGroupBy. 

    If you do not want the user to be able to changing the grouping or sorting, then the easiest thing to do is to hide the GroupByBox:


            private void ultraGrid1_InitializeLayout(object sender, Infragistics.Win.UltraWinGrid.InitializeLayoutEventArgs e)
            {
                UltraGridLayout layout = e.Layout;

                layout.GroupByBox.Hidden = true;
            }

    If you want to display the grouping information in the GroupByBox, but just prevent the user from changing anything, then you need to set AllowGroupBy to false. Note that this property only affects whether the user can change the grouping. It does not prevent you from grouping in code:


            private void ultraGrid1_InitializeLayout(object sender, Infragistics.Win.UltraWinGrid.InitializeLayoutEventArgs e)
            {
                UltraGridLayout layout = e.Layout;
                UltraGridBand band = layout.Bands[0];
                UltraGridOverride ov = layout.Override;

                layout.ViewStyleBand = ViewStyleBand.OutlookGroupBy;
                band.SortedColumns.Add("Int32 1", false, true);
                ov.AllowGroupBy = DefaultableBoolean.False;
            }

    Also note that the user can still change the sort direction of the grouped columns. To disable that, you have to set the HeaderClickAction or cancel the BeforeSortChange event.