jetbet
asked on
Overriding custom button behaviour
I have a form with a Custom button on it. This button has tool strips attached.
I want to override the behaviour of the toolstrip click method on the user control it is on, but although my code gets called I cannot stop the original code being called afterwards.
I have commented out the event handler in the designer and added my own in the user control but nothing seems to stop the original event code overwriting what I am setting the state to.
Original Code
User Control designer (commented out)
Initialisation of event in user control
New Event Code on user control
I want to override the behaviour of the toolstrip click method on the user control it is on, but although my code gets called I cannot stop the original code being called afterwards.
I have commented out the event handler in the designer and added my own in the user control but nothing seems to stop the original event code overwriting what I am setting the state to.
Original Code
private void previousPageToolStripMenuItem_Click(object sender, EventArgs e)
{
NZRB_Global.Utils.LogToolStripMenuItemClick(sender, "previousPageToolStripMenuItem");
if (null != ButtonPreviousPageClicked)
{
ButtonPreviousPageClicked(this, e);
m_pbState = PTRB_STATE.PBS_TAKE;
DisableMenuItemPreviousPage();
this.Text = "Take " + m_CurrentPage + " of " + m_NumberOfPages;
}
}
User Control designer (commented out)
// this.ptrBtnResults.ButtonPreviousPageClicked += new NZRB_Button.PreviewTakeRemoveButton.ButtonPreviousPageHandler(this.ptrBtnResults_ButtonPreviousPageClicked);
Initialisation of event in user control
this.ptrBtnResults.ButtonPreviousPageClicked += new PreviewTakeRemoveButton.ButtonPreviousPageHandler(ButtonPreviousPageClicked);
New Event Code on user control
private void ButtonPreviousPageClicked(object sender, EventArgs e)
{
if (inRaceSceneControl.mainScenes.Contains(NZRB_Global.Consts.DIRECTOR_FF_RESULTS))
{
inRaceSceneControl.ClearScene(true, NZRB_Global.Consts.DIRECTOR_FF_RESULTS, Consts.GFX_LBAR_LAYER);
inRaceSceneControl.ClearScene(false, NZRB_Global.Consts.DIRECTOR_FF_RESULTS, Consts.GFX_LBAR_LAYER);
ptrBtnResults.ResetButton();
}
}
My recommendation: Set the page directive for the aspx page to AutoEventWireup = "false". See what that does for you.
ASKER CERTIFIED SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.