Michael

Michael

  • NA
  • 1
  • 0

Question about click events

Dec 4 2006 1:15 PM
I'm writing a memory or matching game and I've had everything up to the point preventing bugs in the game. I did a click event for all of the picture boxes with switch statements for each picture box and I was wondering how I would make the program ignore when the same box is clicked for both the first and second click. switch(SelectedPictureBox.Name) { case "uiPicBox1": { intCounter++; this.uiPicBox1.Image=null; if(intCounter==1) this.uiFirstClick.Tag=uiPicBox1.Tag; if(intCounter==2) this.uiSecondClick.Tag=uiPicBox1.Tag; } break; case "uiPicBox2": { intCounter++; this.uiPicBox2.Image=null; if(intCounter==1) this.uiFirstClick.Tag=uiPicBox2.Tag; if(intCounter==2) this.uiSecondClick.Tag=uiPicBox2.Tag; I'm wondering how to prevent clicking the same thing and also if(intCounter==2) { if(this.uiFirstClick.Tag.Equals(this.uiSecondClick.Tag)) { uiFirstClick.Tag=0; uiSecondClick.Tag=0; } else { if(uiFirstClick.Tag.Equals(this.uiPicBox1.Tag)) this.uiPicBox1.Image=Image.FromFile("C:\\Documents and Settings\\Michael\\Desktop\\Memory Project\\Picture Folder\\Index.bmp"); if(uiFirstClick.Tag.Equals(this.uiPicBox2.Tag)) this.uiPicBox2.Image=Image.FromFile("C:\\Documents and Settings\\Michael\\Desktop\\Memory Project\\Picture Folder\\Index.bmp"); what would prevent me from being able to go back after images have been matched and clicking on them. right now when i click on already matched images it assigns them to first and second click. Any help is appreciated.