BrightIdeasSoftware.ObjectListView.ApplyExtendedStyles C# (CSharp) Method

ApplyExtendedStyles() protected method

Apply all required extended styles to our control.

Whenever .NET code sets an extended style, it erases all other extended styles that it doesn't use. So, we have to explicit reapply the styles that we have added.

Normally, we would override CreateParms property and update the ExStyle member, but ListView seems to ignore all ExStyles that it doesn't already know about. Worse, when we set the LVS_EX_HEADERINALLVIEWS value, bad things happen (the control crashes!).

protected ApplyExtendedStyles ( ) : void
return void
        protected virtual void ApplyExtendedStyles()
        {
            const int LVS_EX_SUBITEMIMAGES = 0x00000002;
            //const int LVS_EX_TRANSPARENTBKGND = 0x00400000;
            const int LVS_EX_HEADERINALLVIEWS = 0x02000000;

            const int STYLE_MASK = LVS_EX_SUBITEMIMAGES | LVS_EX_HEADERINALLVIEWS;
            int style = 0;

            if (this.ShowImagesOnSubItems && !this.VirtualMode)
                style ^= LVS_EX_SUBITEMIMAGES;

            if (this.ShowHeaderInAllViews)
                style ^= LVS_EX_HEADERINALLVIEWS;

            NativeMethods.SetExtendedStyle(this, style, STYLE_MASK);
        }
ObjectListView