gpt4 book ai didi

c# - .NET Custom UserControl 的内容在调整父级大小时消失

转载 作者:太空宇宙 更新时间:2023-11-03 16:38:07 25 4
gpt4 key购买 nike

我派生了 .NET UserControl,以制作我自己的 PictureList 类。但是,当我调整控件的父级大小时,控件的内容消失了。没有发出 Resize 事件或其他任何事件。我遗漏了与问题无关的代码。

    public ImageList(int width, int height)
{
ClientSize = new Size(width, height);
ResizeRedraw = true;

}


// Ensure background transparency will be handled corretly.
protected override CreateParams CreateParams
{
get {
CreateParams cp = base.CreateParams;
cp.ExStyle |= 0x20; // WS_EX_TRANSPARENT
return cp;
}
}

protected override void OnPaint(PaintEventArgs e)
{
MessageBox.Show("This messagebox is only shown upon the first drawing, but not after the magically disappearing of the contents");

img = /*the image to draw*/
rect = /*the size of the image*/
e.Graphics.DrawImage(img, rect);
}

最佳答案

是否需要启用AutoRedraw

关于c# - .NET Custom UserControl 的内容在调整父级大小时消失,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8496057/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com