private void pictureBox1_Paint(object sender, PaintEventArgs e) { if (this.pictureBox1.Image.IsNull()) { return; } if (this.folv_ObjectDetail.SelectedObjects != null && this.folv_ObjectDetail.SelectedObjects.Count > 0) //if checkbox button is enabled { try { foreach (ClsPrediction pred in this.folv_ObjectDetail.SelectedObjects) { if (pred != null) { AITOOL.DrawAnnotation(e.Graphics, pred, this.pictureBox1.Image.Width, this.pictureBox1.Image.Height, this.pictureBox1.Width, this.pictureBox1.Height); pictureBox2.Image = AITOOL.CropImage(OriginalBMP, pred.GetRectangle()); } } } catch (Exception ex) { } } }