Code in User Control (Windows User Control).
I have a button and when click on the button some logic will fire.
below is button event.
private void btnCancel_Click(object sender, EventArgs e)
{
// Some Logic
}
I have Main form (Windows form)
I am adding the above user control in a Panel of my Main Winform.
From here I want to invoke the user control btnCancel_Click event using some function Keys Like (F3,F4).
This is a very new thing for me. Please help me in this regard.
Thanks .
Krishna
Set your parent form
KeyPreviewattribute to true and then in theKeyDownevent of your parent form, look forif(e.KeyCode == Keys.F3), then write a public method for your usercontrol which fires thebtnCancel_Click. You can access it from your parent form.Parent Form:
Usercontrol: