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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T10:49:50+00:00 2026-05-23T10:49:50+00:00

I am developing a C# WinForms application. On the FormLoad event, I dynamically create

  • 0

I am developing a C# WinForms application. On the FormLoad event, I dynamically create and add to the form 100 buttons without text, but with names like button1, button2 etc. Also, onto these buttons, after their creation, I dynamically link a unique event handler for the ButtonClick event. How can I access the button’s properties from within the event handler (more specifically the button name)?
If I use this.Name, I get the name of the form, and not the name of the button.

Later Edit: (for those who might wonder here in search of solutions)

private void function1()
{
    Button a = new Button();

    a.Name = "button" + (i * j).ToString();
    a.Click += new EventHandler(OnFieldButtonClicked);
}

private void OnFieldButtonClicked(object sender, EventArgs e)
{
    Button button = (Button)sender;
    MessageBox.Show(button.Name);
}
  • 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-05-23T10:49:51+00:00Added an answer on May 23, 2026 at 10:49 am

    The sender argument is the event handler encapsulates an instance of the object that has triggered the event:

    Button button = (Button) sender;
    String text = button.Text;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm developing application in WPF but some components are written using WinForms. I wan't
I'm developing a WinForms application and on one form, I use a GroupBox to
While developing a WinForms application, I came across what I believe is a bug
I'm developing a WinForms application (.Net 3.5, no WPF) where I want to be
We are developing a Winforms application and in the process of optimizing the start-up
I am developing a WinForms application using the MVP pattern. I would like to
Developing a .NET WinForms application: how can I check if the window is in
We are developing a multilingual Winforms application using visual studio 2008. I am trying
I am developing a Windows .NET application (WinForms) and I need to simulate a
I'm developing a WinForms c# 3.0 application. Our designer created quite a lot of

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.