我正在尝试使用 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,但没有任何反应。
不知道为什么。