Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9227507
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T05:05:54+00:00 2026-06-18T05:05:54+00:00

Code in User Control (Windows User Control). I have a button and when click

  • 0

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

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T05:05:56+00:00Added an answer on June 18, 2026 at 5:05 am

    Set your parent form KeyPreview attribute to true and then in the KeyDown event of your parent form, look for if(e.KeyCode == Keys.F3), then write a public method for your usercontrol which fires the btnCancel_Click. You can access it from your parent form.

    Parent Form:

    private void Form1_KeyDown(object sender, KeyEventArgs e)
    {
        if (e.KeyCode == Keys.F3)
        {
            MyUserControl.FireButtonEvent();
        }
    }
    

    Usercontrol:

    public void FireButtonEvent()
    {
      this.btnCancel_Click(null, EventArgs.Empty);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a user control which uses objects as inner properties (some code is
I have a small user control with 'Browse' button for selecting some file and
Below is my entire code from a User control that contains the YUI Uploader.
I created a DatePicker user control (ASP code below, no code behind) which is
I have extended a server control (not a user control) and put the code
I have a user control that has a text box and a button. I
I have a custom control with an event handler when you click on it.
I a WPF application I have the following event-handler of a button-click in a
I've created a simple user control in Windows Forms that consists of a button
In my user control I have a button that, when clicked, would raise a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.