Chris,
I am pretty sure that is not the case, here is the code that is used when
the form first loads (and works ok) and the method for a new game:
private void Form1_Load(object sender, EventArgs e)
{
/////////////////////////////////////////////////
blnfirstTurn = true; //Sets the value to true for the first pick
intNumMatches = 0; //increments each time a pair is found
intNumTries = 0;
lblMsg.Text = "Click a box";
lblPick1.Text = "";
lblPick2.Text = "";
set_up_blanks();
load_names();
swap_names(); //Shuffles the names
/////////////////////////////////////////////////
}
private void cmdStart_Click(object sender, EventArgs e)
{
//Here we are resetting for a new game
blnfirstTurn = true;
intNumMatches = 0;
intNumTries = 0;
lblMsg.Text = "Click a box";
lblPick1.Text = "";
lblPick2.Text = "";
set_up_blanks();
load_names();
swap_names();
}
> > Yes, basically in a nutshell that is my question: Why the ClickHandler()
> > method is being called for the same control twice? I like your idea of
[quoted text clipped - 4 lines]
>
> Chris
Peter Duniho - 20 Jul 2007 17:31 GMT
> Chris,
>
> I am pretty sure that is not the case, here is the code that is used when
> the form first loads (and works ok) and the method for a new game:
For what it's worth, while I don't see anything obvious in the code you
posted, it's really not a good idea to duplicate code like that.
Put all of your shared initialization code into a single function, and
then call that function from both places.
This is better for a variety of reasons, but IMHO the biggest reason is
that if you have a bug in the shared code, you only have to fix it once.
:)
This has nothing to do with your actual question, but should help you in
the long run.
As far as the code you posted goes, it's impossible to know for sure that
nothing odd is going on, because you have three different functions called
during initialization that you didn't post. So something could be
happening in those functions that is causing a problem. Maybe not, but we
don't know.
I still think the debugger is your best bet. It's possible that someone
might be able to identify your problem by code inspection, but you've got
the whole program there and running, and watching what it does as it runs
is likely to be the best way to solve an issue like this.
Pete