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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T23:38:34+00:00 2026-06-01T23:38:34+00:00

I have 6 text boxes in 6 lines, 36 in all. Line one, box

  • 0

I have 6 text boxes in 6 lines, 36 in all. Line one, box one is called L1N1, line one, box two is L1N2 etc. I want to dynamically assign values to these text boxes using a string…can this be done in C#? E.g.

    private void Generate_Click(object sender, EventArgs e)
    {
        int[,] numbers = new int[6, 6];
        int lin = 0;
        while (lin < 6)
        {
            lin++;
            int num = 0;
            while (num < 6)
            {
                num++;
                Random random = new Random();
                int randomNum = random.Next(1, 45);
                "L" + lin + "N" + num /* <--here is my string (L1N1) i want to 
                                          set my textbox(L1N1).text to a value
                                          randomNum!*/
  • 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-01T23:38:35+00:00Added an answer on June 1, 2026 at 11:38 pm

    I echo Jon Skeet’s sentiments. If you want to be able to locate a control by some row/column system, the easiest way to do so is to put the controls themselves into a collection that allows them to be indexed in a similar way:

    var textboxes = new TextBox[6][];
    textboxes[0] = new TextBox[]{txtL1N1, txtL1N2, txtL1N3, txtL1N4, txtL1N5, txtL1N6};
    //create the rest of the "lines" of TextBoxes similarly.
    
    //now you can reference the TextBox at Line X, number Y like this:
    textboxes[X-1][Y-1].Text = randomNum.ToString();
    

    Now, if you REALLY wanted to access these textboxes by some string value, you would use the Tag property, which is a general-purpose property of most Controls. You could also name all your textboxes according to some system. Then, a little Linq can get you the textbox you want:

    this.Controls.OfType<TextBox>()
       .Single(t=>t.Tag.ToString() == "L1N1").Text = randomNum.ToString();
    

    However, understand this will be VERY slow; you’ll be searching the full collection of all controls that exist on the Form every time you want one. Indexing will be much faster.

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

Sidebar

Related Questions

I have a form with two text boxes, one select drop down and one
I have two text boxes t1 and t2 in an html page. I'd like
I have 6 text boxes on an asp page and one search button. Users
I have two input text boxes which are decimal. The sum of the two
I have a table which has two text boxes and an image beside it
Ive got a Form application in VB.NET. I have many text boxes on one
I have some text: A block of text is a stack of line boxes.
I have text input boxes. There is validation for each of the boxes using
I have three text boxes on the stage id=red, blue, green same as the
I have 2 text boxes and a submit button.On clicking on the submit button

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.