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
80
ListView Group Divider
posted

How can I change the default gradiant (blue to white) of the Group divider ?


Parents
No Data
Reply
  • 69832
    Offline posted

    You can't change that color via the public object model...the following code sample demonstrates how to do it using the IUIElementCreationFilter interface: 

    AppearanceData appearance = new AppearanceData();
    appearance.BackColor = Color.Red;
    appearance.BackColor2 = Color.Pink;
    this.listView.CreationFilter = new GroupDividerCreationFilter( appearance );
    .
    .
    .
    #region GroupDividerCreationFilter
    /// <summary>
    /// IUIElementCreationFilter implementation which Handles the display of
    /// checkboxes for UltraListViewItems in Thumbnails mode.
    /// </summary>
    public class GroupDividerCreationFilter : IUIElementCreationFilter
    {
        private AppearanceData appearance;

        /// <summary>
        /// Creates a new instance of the GroupDividerCreationFilter class.
        /// </summary>
        /// <param name="appearance">Defines the BackColor, BackColor2, and BackGradientStyle properties for the divider element.</param>
        public GroupDividerCreationFilter( AppearanceData appearance )
        {
            this.appearance = appearance;
        }

        #region IUIElementCreationFilter Members

        void IUIElementCreationFilter.AfterCreateChildElements(UIElement parent)
        {
            if ( parent is UltraListViewGroupUIElement )
            {
                UltraListViewGroupHeaderLineUIElement dividerElement =
                    parent.GetDescendant( typeof(UltraListViewGroupHeaderLineUIElement) )
                    as UltraListViewGroupHeaderLineUIElement;

                if ( dividerElement != null )
                {
                    Rectangle rect = dividerElement.Rect;
                    UIElementsCollection childElements = parent.ChildElements;
                    childElements.Remove( dividerElement );

                    GroupDividerUIElement newElement = new GroupDividerUIElement(parent as UltraListViewGroupUIElement, this.appearance);
                    newElement.Rect = rect;
                    childElements.Add( newElement );
                }
            }
        }

        bool IUIElementCreationFilter.BeforeCreateChildElements(UIElement parent)
        {
            //  Return false to signify that the elements
            //  should be added as they normally are.
           return false;
        }

        #endregion IUIElementCreationFilter Members

        #region GroupDividerUIElement class
        public class GroupDividerUIElement : UltraListViewGroupHeaderLineUIElement
        {
            private AppearanceData appearance;

            /// <summary>
            /// Creates a new instance of the GroupDividerUIElement class.
            /// </summary>
            public GroupDividerUIElement( UltraListViewGroupUIElement parent, AppearanceData appearance ) : base( parent )
            {
                this.appearance = appearance;
            }

            protected override void InitAppearance(ref AppearanceData appearance, ref AppearancePropFlags requestedProps)
            {
                AppearanceData.Merge( ref appearance, ref this.appearance, ref requestedProps );
                base.InitAppearance(ref appearance, ref requestedProps);
            }
        }
        #endregion GroupDividerUIElement class
    }
    #endregion GroupDividerCreationFilter

Children
No Data