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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T06:16:08+00:00 2026-06-13T06:16:08+00:00

I have a bunch of text boxes in a panel on my C# Winform.

  • 0

I have a bunch of text boxes in a panel on my C# Winform. Each row of text boxes are named like this:

tb1 tbNickName1 comboBox1
tb2 tbNickName2 comboBox2
tb3 tbNickName3 comboBox3

and so on.

I have a button next to each of the rows of text boxes. But instead of having the button point to a different event for each button, I want to point the button to just the button1_Click event and have it do all of the processing there. I know how to do this and all my buttons point to the button1_Click event.

But I need to be able to determine which button it was called from (which I am able to do), but I need to manipulate the name of the text boxes in the event so I can do the processing based on what row I am in/button that I am calling from.

For example, if I am in row number 2 where the tb2 tbNickName2 comboBox2 textboxes are, then I need to be able to have the button1_Click event know this and automatically assign the tb2 tbNickName2 comboBox2 values to the tmp variables that I use in the example below.

private void button1_Click(object sender, EventArgs e)
{
       Button bt = (Button) sender; //will return 'button1'

       string tmpEmail = null;
       string tmpNickName = null;
       string tmpGroup = null;

       //I don't want to hard code the tb1.Text value here, I want to have
       // the namechange based on which (Button) sender it was called from.

       // For example button1 should assign all the
       // tb1    tbNickName1   comboBox1 values

       //If called from button2, then it should assign the
       //tb2    tbNickName2   comboBox2 values instead

       //How can I do this so tb1.Text is based off of the button # that I am 
       //calling for example tb(bt).Text would be cool but that does not work.

       tmpEmail = tb1.Text; //What do I change tb1.Text to based on button #?

       tmpNickName = tbNickName1.Text; //What do I change tbNickName1.Text to?

       tmpGroup = comboBox1.Text;//What do I change comboBox1.Text to?
}

I know that I have not explained this very well, but it is the best I can do.

  • 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-13T06:16:09+00:00Added an answer on June 13, 2026 at 6:16 am
    Button button = sender as Button;
    string buttonIndex = button.Name.Substring(6);
    string tempEmail = (this.Controls["tb" + buttonIndex] as TextBox).Text;
    string tmpNickName = (this.Controls["tbNickName" + buttonIndex] as TextBox).Text;
    string tmpGroup = (this.Controls["comboBox" + buttonIndex] as ComboBox).Text;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have bunch of lists like this: out[3] [[3]] [1] forum=28&mid=11883 [2] forum=29&mid=11884 out[4]
I have a bunch of input text boxes that have the attribute ORIGINAL set
I have a bunch of text boxes and a save button to update something.
I have a form with a number of text boxes for user input (this
I have a bunch of text boxes in my ASP.NET MVC view which are
I have a bunch of text boxes bound to table adapters, when I fill
I have a bunch of rows in a form like this <tr> <td nowrap><input
I have a bunch of items (text, image, mixed content, etc) that I want
I have a bunch of log files which are pure text. Here is an
I have whole bunch of <div class=productlistname><a href=#>The Text!</a></div> . What I want to

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.