.NET UserControl을 파생시켜 자신의 PictureList 클래스를 만들었습니다. 그러나 컨트롤의 부모 크기를 조정할 때 컨트롤의 내용이 사라집니다. Resize 이벤트가 발생하지 않습니다. 질문과 관련없는 코드는 생략했습니다..NET 사용자 지정 UserControl의 내용은 부모 크기가 조정될 때 사라집니다.
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);
}
오류를 재현 할 수 없습니다. 또한 왜 지구상에서 OnPaint의 MessageBox를 가지고 있는지 알지 못합니다 (추상적 인 목적으로 만). 프로그래밍 방식으로 또는 디자이너와 함께 이러한 컨트롤을 생성하고 있습니까? –
프로그래밍 방식으로 생성했습니다. MessageBox는 단지 설명을위한 것입니다. 문제는 컨트롤이 완벽하게 그려진다는 것입니다. 디자이너에서 사용하고, 레이아웃에 배치하고, 레이아웃을 폼의 측면에 고정시킵니다. 양식의 크기를 조정하면 이미지가 사라집니다. – Supergrover
내용은 무엇입니까? –