Drawing a transparent button

后端 未结 4 1505
不知归路
不知归路 2020-11-29 07:35

I\'m trying to create a transparent button in C# (.NET 3.5 SP1) to use in my WinForms application. I\'ve tried everything to get the button to be transparent (it should show

4条回答
  •  刺人心
    刺人心 (楼主)
    2020-11-29 08:12

    I'm not sure ButtonBase supports transparency... have you checked that out?

    I've written a number of transparent controls, but I have always inherited from Control or UserControl.

    When you want to block out a control painting it's background - you should override OnPaintBackground instead of OnPaint and not call the base class.

    Filling a rectangle with Brushes.Transparent is funny though - you're painting with an invisible color over what's aready there. Or to put it another way: it does nothing!

提交回复
热议问题