leocb / MaterialSkin

Theming .NET WinForms, C# or VB.Net, to Google's Material Design Principles.
MIT License
437 stars 132 forks source link

No UserControl support #320

Closed Exorion1er closed 2 years ago

Exorion1er commented 2 years ago

Is there any plan to support UserControl in the future ? Right now, when trying to add a UserControl to my form, because the controls don't like a transparent background, they make a black background instead, which obviously breaks the theme.

valimaties commented 2 years ago

Hi @ExoKalork As I know, writing the code below to your UserControl will set its background as transparent:

protected override CreateParams CreateParams
{
    get
    {
        CreateParams cp = base.CreateParams;
        cp.ExStyle |= 0x20;
        return cp;
    }
}

Example of a Test UserControl: Test.cs

public partial class Test : UserControl
    {
        public Test()
        {
            InitializeComponent();
        }

        protected override CreateParams CreateParams
        {
            get
            {
                CreateParams cp = base.CreateParams;
                cp.ExStyle |= 0x20;
                return cp;
            }
        }
    }

UserControl

Exorion1er commented 2 years ago

Oh this indeed looks right, thanks a lot !