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 8135147
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T10:19:13+00:00 2026-06-06T10:19:13+00:00

In a WinForms solution, you have multiple controls of the same type. You need

  • 0

In a WinForms solution, you have multiple controls of the same type. You need to add an event handler to each of the control and at the current time the event handler will be doing the same thing. You do not expect there to be difference between them down the road any reason.

eg:

ScheduledPatientsGrid.ProcessGridKey += ScheduledPatientsGrid_ProcessGridKey;
RecentPatientsGrid.ProcessGridKey += RecentPatientsGrid_ProcessGridKey;
RecentPatientsGrid.ProcessGridKey += RecentPatientsGrid_ProcessGridKey;

... 

private void ScheduledPatientsGrid_ProcessGridKey(object sender, KeyEventArgs e)
{
   ...
}

private void RecentPatientsGrid_ProcessGridKey(object sender, KeyEventArgs e)
{
   ...
}

private void PatientsGrid_ProcessGridKey(object sender, KeyEventArgs e)
{
   ...
}

Now is it better to sharing an single Event Handler between the different events as shown below or use different ones like in the code sample shown above?

ScheduledPatientsGrid.ProcessGridKey += ProcessGridKey;
RecentPatientsGrid.ProcessGridKey += ProcessGridKey;
RecentPatientsGrid.ProcessGridKey += ProcessGridKey;                


private void ProcessGridKey(object sender, KeyEventArgs e)
{
  ...
}

In the following page, Microsoft seems to suggest that sharing is better, however I notice that they have not updated it since .NET 2.0 (ie: Visual Studio 2008)

http://msdn.microsoft.com/en-us/library/4ac48519%28v=vs.90%29.aspx

Is there a Guide that makes a best practices recommendation in this case?

  • 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-06T10:19:16+00:00Added an answer on June 6, 2026 at 10:19 am

    I would absolutely use the same method. What possible benefit is there to having multiple methods which do exactly the same, none of which is named to say what it does?

    Personally I abhor the source_EventName convention that Visual Studio spawns. I prefer to give my event handler methods meaningful names which say what they do. Then when you look down the event handler list in the designer, you can see that when a button is clicked, X will happen rather than “the button’s click event handler will be called” which is useless.

    Alternatively, use lambda expressions to subscribe to the events and call meaningful methods with meaningful parameters. (The sender and args are often useless for event handlers.)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a solution with 2 projects: My Application 1.2.54 (C# WinForms) My Application
I have multiple business objects in my application (C#, Winforms, WinXP). When the user
I have a simple WinForms solution in VS 2010. Whenever I build it, output
I have just deployed my VB.net VS2008 winforms solution to the test server. When
I'm working on WinForms application. I have group of tests classes, each class performs
I have a solution that has a plain old asp.net website and a winforms
I need some help regarding Visual Studio solution and project organization. I have a
I have 2 C# projects in my solution, both of them DLLs: MyApp.UI.WPF.csproj MyApp.UI.WinForms.csproj
I have a c# .net winforms solution and I want to create two different
I have a VS2010 Setup project for a C# Winforms solution. Deployment of updates

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.