简体   繁体   中英

press enter key and user control event happen

I have a userControl(DT_Navigator) . there is a button ( btnNew ) in it. I wrote the click button event for it:

public void btnNew_Click(object sender, EventArgs e)
{
        btnNew.Enabled = false;
}

I use the user control button in another project and wrote another click event for it:

public void btnNew_Click(object sender, EventArgs e)
{
        btnNew.Enabled = false;
}

but, when I press the Enter key, just the first event that I defined in user control, executes. However I want both events to execute.

when I click on btnNew , both events trigger, but when I press Enter key, only one event triggers.

how can I fix the problem? Thanks...

尝试这个:

DT_Navigator.btnNew.Click += new EventHandler(DTnewItem);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM