Panel Class不工作,我错过了什么?

时间:2013-08-09 01:36:44

标签: c# panel

我正在尝试使用DoubleBuffered,我认为它不起作用。 我知道很多人已经提出了这个话题,但我的问题并不完全相同,所以我为什么要这样做,因为我还没有发现任何内容。

所以我在Form类的底部创建了一个类,

public class MyDisplay : Panel
{
    public MyDisplay() :base()
    {
        this.DoubleBuffered = true;

        this.SetStyle(ControlStyles.UserPaint |
          ControlStyles.AllPaintingInWmPaint |
          ControlStyles.ResizeRedraw |
          ControlStyles.ContainerControl |
          ControlStyles.OptimizedDoubleBuffer |
          ControlStyles.SupportsTransparentBackColor
          , true);
        this.SetStyle(ControlStyles.AllPaintingInWmPaint, true);
        this.SetStyle(ControlStyles.OptimizedDoubleBuffer, true);
        this.UpdateStyles();
    }
}

然后在顶部我添加了:

private MyDisplay panelm = new MyDisplay();

然后我要显示背景:

panelm.BackgroundImage = Image.FromStream(new MemoryStream(reader.ReadBytes(reader.ReadInt32())));

它不起作用。 我可能错过了一些东西。 我试过改变它的大小,我把它设置为600x480,但没有任何反应。

不确定原因。

0 个答案:

没有答案