c# Resize parent control when a child pictureBox changes the Image
问题 I have a UserControl that contains a PictureBox and a Label. The Control loads three different images in PictureBox on different events (fore example onMouseEnter, OnMouseLeave). As the images can have different sizes, I neet to resize the pictureBox and the control itself. Below is provided the control's OnPaint event but this does not work. protected override void OnPaint(PaintEventArgs pe) { if (pictureBox.Image != null) { this.Width = this.pictureBox.Image.Size.Width; this.Height = this