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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T14:09:46+00:00 2026-06-10T14:09:46+00:00

I have about 60 textboxes and it’s a mess when each one has its

  • 0

I have about 60 textboxes and it’s a mess when each one has its own code section. For some events actions are the same and for others there can be a dictionary with actions. Problem is I don’t know how to iterate through textboxes, get current textbox reference and run some methods which will change current textbox’s text.

UPD: What I’m trying to do is make all textboxes run AllTextboxesEnter method which will change their text according to textbox’s name, run AllTextboxesLeave method which will perform some action from action dictionary according to textbox’s 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-06-10T14:09:48+00:00Added an answer on June 10, 2026 at 2:09 pm

    Assuming I understand the question correctly, here’s my answer to the interpretation of the question

    private void Form1_Load(object sender, EventArgs e)
    {
        foreach (TextBox tb in this.Controls.OfType<TextBox>())
        {
            tb.Enter += new EventHandler(textBoxAll_Enter);
            tb.Leave += new EventHandler(textBoxAll_Leave);
        }
    }
    
    private void textBoxAll_Enter(object sender, EventArgs e)
    {
        ((TextBox)sender).Text = "textbox gained focus";
    }
    
    private void textBoxAll_Leave(object sender, EventArgs e)
    {
        ((TextBox)sender).Text = "textbox lost focus";
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a aspx page with about 200 textboxes with onkeyup events that some
I have a login page that has several textboxes on the page, one of
i have about 60 fragments ListFragment , now i use each Listfragment with another
I have about 8 entities that all have a one to one relationship with
I have about 100 TextBoxes in a Form. I need to validate them if
I have some textboxes on a webform that have ids like this: txtFinalDeadline_1 txtFinalDeadline_2
Total beginner question about jQuery: I have a Form that contains several TextBoxes (input
I have a form that contains two input textboxes, one called serial and the
Hello guys, just want you to ask something about my code... I have 5
I have a control where is about 100 hundred TextBoxes, and I need for

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.