调用OnPaintBackground

我正在努力使表单的背景变得透明,所以我在一些随机项目中测试了以下代码并且它工作得很好,但现在当我将它应用于新项目时,它在加载过程中没有被读取,因为我试图突破!! 我究竟做错了什么?

protected override void OnPaintBackground(PaintEventArgs e) { Bitmap bmp = new Bitmap(AFK_AIESEC.Properties.Resources.splash); this.locked.BackgroundImage = bmp; } 

如果要确保覆盖OnPaint方法,则应在构造函数中按如下方式设置表单样式:

 this.SetStyle(ControlStyles.AllPaintingInWmPaint | ControlStyles.OptimizedDoubleBuffer | ControlStyles.ResizeRedraw | ControlStyles.DoubleBuffer | ControlStyles.UserPaint , true); 

ControlStyles.UserPaint的重要设置告诉它你想要自己处理这幅画。