Ejemplo n.º 1
0
        public static void RemoveDynamicBandsAndColumns(GridBand onThisBand, IDynamicPropertyList headerList)
        {
            if (onThisBand.View == null)
            {
                return;
            }

            onThisBand.View.BeginDataUpdate();
            foreach (IDynamicProperty header in headerList.GetProperties(true))
            {
                BandedGridColumn foundColumn = null;
                foreach (GridBand childBand in onThisBand.Children)
                {
                    foreach (BandedGridColumn column in childBand.Columns)
                    {
                        if (column.Tag != null)
                        {
                            var keyValue = column.Tag as string;

                            if (keyValue != null && keyValue == header.Key)
                            {
                                foundColumn = column;
                                break;
                            }
                        }
                    }

                    if (foundColumn != null)
                    {
                        childBand.Columns.Remove(foundColumn);
                        foundColumn.Dispose();
                        break;
                    }
                }

                // Jetzt noch die Nutzlosen Bänder entfernen.
                // Das machen wir mit der üblichen EntfernungsTaktik: Von hinten nach vorne, damit wir uns nicht den Boden unter den Füssen wegziehen.
                // (Foreach geht sowieso nicht)
                for (int i = onThisBand.Children.Count - 1; i >= 0; i--)
                {
                    if (onThisBand.Children[i].Columns.Count == 0)
                    {
                        onThisBand.Children.Remove(onThisBand.Children[i]);
                    }
                }
            }
            onThisBand.View.EndDataUpdate();
        }
Ejemplo n.º 2
0
        public static void RemoveDynamicColumns(GridBand onThisBand, IDynamicPropertyList propertyList)
        {
            if (onThisBand.View == null)
            {
                return;
            }

            onThisBand.View.BeginDataUpdate();
            foreach (IDynamicProperty p in propertyList.GetProperties(true))
            {
                BandedGridColumn foundColumn = null;

                foreach (BandedGridColumn column in onThisBand.Columns)
                {
                    if (column.Tag != null)
                    {
                        var keyValue = column.Tag as string;

                        if (keyValue != null)
                        {
                            if (keyValue == p.Key)
                            {
                                foundColumn = column;
                            }
                        }
                    }
                }

                if (foundColumn != null)
                {
                    onThisBand.Columns.Remove(foundColumn);
                    foundColumn.Dispose();
                }
            }
            onThisBand.View.EndDataUpdate();
        }