0

The system will display one image on PictureBox from the Upload folder(contains multiple images). After the user clicks on the fail button in Form4 then it will show the Form6 to let the user choose a list of defect categories then click on the BtnAdd_Click()in Form6.

When the user clicks on BtnAdd_Click() in Form6 then the image displays in the PictureBox in Form4 will move to the next image incrementImage().

I want to check whether the BtnAdd_Click() was clicked in Form6 and pass to Form4 to perform the incrementImage() function. May I know how to do this thanks.

Form4.cs

public void incrementImage()
        {

            nCurrentItem++;
            firstImage++;

            if (nCurrentItem > nTotalNumber)
                nCurrentItem = nTotalNumber;

            else if (nCurrentItem < nTotalNumber)
            {
                Image img;
                using (var bmpTemp = new Bitmap(ImageFilenames[nCurrentItem]))
                {
                    img = new Bitmap(bmpTemp);
                }
                PicBox.Image = img;

            }

            imgCounter.Text = firstImage.ToString() + " / " + nTotalNumber.ToString();
        }

Form6. cs

private void BtnAdd_Click(object sender, EventArgs e)
            {
                if (listBoxFailCategories.SelectedIndex == -1)
                {
                    MessageBox.Show("Please select any defect category");
                }
                else
                {
                    var tempDefectCategory = "";
    
                foreach (string item in listBoxFailCategories.SelectedItems)
                {
                    string defectFolder = Path.Combine(Value, item);
                    File.Copy(Image, Path.Combine(defectFolder, Path.GetFileName(Image)), true);

                    added = true;

                    tempDefectCategory = tempDefectCategory + item.ToString() + ",";

                    FullPathName = Path.Combine(defectFolder, Path.GetFileName(Image));

                    this.Close();
                }
                DefectCategory = tempDefectCategory;
                File.Delete(Image);
            }
        }
Vektor
  • 1
  • 2
  • 1
    Did you know you're allowed to rename forms just like every other class/property/variable/control? – Caius Jard Oct 13 '21 at 07:26
  • `this.Close();` …?... this would mean that if there is at least one selected item… then… the `foreach` loop would only execute “once” and the last two lines of code will not execute? Is this intended? – JohnG Oct 13 '21 at 07:28
  • @JohnG it works for me – Vektor Oct 13 '21 at 07:31

0 Answers0