Click here to Skip to main content
15,897,704 members

Comments by Vektor 2021 (Top 7 by date)

Vektor 2021 27-Oct-21 3:17am View    
typo
Vektor 2021 13-Oct-21 11:10am View    
Because I follow your code. Isn't correct?
Vektor 2021 13-Oct-21 10:44am View    
How should trigger the OnDefectButtonPressed method in Form 4
Vektor 2021 13-Oct-21 10:44am View    
Deleted
How should trigger the OnDefectButtonPressed method in Form 1
Vektor 2021 13-Oct-21 10:00am View    
I followed yours and added but can't work.


Form1.cs

Form6 fm6; //added new
public Form4()
{
InitializeComponent();

fm6 = new Form6(); //added new
fm6.DefectButtonPressed += OnDefectButtonPressed; //added new

}

private void OnDefectButtonPressed() //added new
{
incrementImage();
}

Form6.cs

public Action DefectButtonPressed; //added new

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));

}
DefectCategory = tempDefectCategory;
File.Delete(Image);
if (DefectButtonPressed != null) DefectButtonPressed(); //added new
this.Close();
}
}