By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
454,497 Members | 2,497 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 454,497 IT Pros & Developers. It's quick & easy.

Click event seems to fire multiple times

P: n/a
DEK
Stepping through my code the click eventhandler code
executes through a few times before it finally stops.
Even though I only click the button once, is there a reason
for this, I have a few if else and method calls in the
eventhandler.

--
Thanks
DEK
Nov 13 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
DEK,

Are these method calls doing anything that could trigger the click
event? Is your click event handler hooked up to multiple event handlers and
then you are calling other methods that could possibly cause those events to
be fired?

Can you post some sample code?
--
- Nicholas Paldino [.NET/C# MVP]
- ni**************@exisconsulting.com

"DEK" <DE*@DEK.COM> wrote in message
news:MP************************@news.cis.dfn.de...
Stepping through my code the click eventhandler code
executes through a few times before it finally stops.
Even though I only click the button once, is there a reason
for this, I have a few if else and method calls in the
eventhandler.

--
Thanks
DEK

Nov 13 '05 #2

P: n/a
DEK
In article <OH**************@TK2MSFTNGP10.phx.gbl>,
ni**************@exisconsulting.com says...
DEK,

Are these method calls doing anything that could trigger the click
event? Is your click event handler hooked up to multiple event handlers and
then you are calling other methods that could possibly cause those events to
be fired?

Can you post some sample code?

MainForm is a singleton form, InfoView is a user control.
the class is a panel of buttons and has methods to set them
enabled/disabled in certain ways, I.e. (this.ShowAddEditButtons).

private void add_Click(object sender, EventArgs e)
{
MainForm form = MainForm.GetInstance();
Contestant contestant = form.CurrentNode.Tag as Contestant;

// Root View
if (!form.InfoView.Visible && form.TableListView.Visible)
{
form.TableListView.Visible = false;
form.InfoView.Visible = true;

form.InfoView.Table = contestant.Blank.Tables
[Constants.Info];

form.InfoView.HeadingCat = "Adding a new";
form.InfoView.RefreshControl(true);
}

// Composite View
else if(form.InfoView.Visible && form.TableListView.Visible)
{
form.TableListView.Visible = false;
form.InfoView.Table = Season.GetInstance
(null).Individuals.Blank.Tables[Constants.Info];

form.InfoView.HeadingCat = contestant.Name + " - Adding a
new";

form.InfoView.RefreshControl(true);
}

// Change button views
this.ShowAddEditButtons();
form.InfoView.Focus();

}
--
Thanks
DEK
Nov 13 '05 #3

P: n/a
DEK
In article <MP************************@news.cis.dfn.de>, DE*@DEK.COM
says...
In article <OH**************@TK2MSFTNGP10.phx.gbl>,
ni**************@exisconsulting.com says...
DEK,

Are these method calls doing anything that could trigger the click
event? Is your click event handler hooked up to multiple event handlers and
then you are calling other methods that could possibly cause those events to
be fired?

Can you post some sample code?

MainForm is a singleton form, InfoView is a user control.
the class is a panel of buttons and has methods to set them
enabled/disabled in certain ways, I.e. (this.ShowAddEditButtons).

private void add_Click(object sender, EventArgs e)
{
MainForm form = MainForm.GetInstance();
Contestant contestant = form.CurrentNode.Tag as Contestant;

// Root View
if (!form.InfoView.Visible && form.TableListView.Visible)
{
form.TableListView.Visible = false;
form.InfoView.Visible = true;

form.InfoView.Table = contestant.Blank.Tables
[Constants.Info];

form.InfoView.HeadingCat = "Adding a new";
form.InfoView.RefreshControl(true);
}

// Composite View
else if(form.InfoView.Visible && form.TableListView.Visible)
{
form.TableListView.Visible = false;
form.InfoView.Table = Season.GetInstance
(null).Individuals.Blank.Tables[Constants.Info];

form.InfoView.HeadingCat = contestant.Name + " - Adding a
new";

form.InfoView.RefreshControl(true);
}

// Change button views
this.ShowAddEditButtons();

It was this last line^^^^

That method called refreshControl which reattached all the handlers
again, I moved the attaching of handlers to the constructor so they only
attached once, thanks.

--
Thanks
DEK
Nov 13 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.