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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T15:09:31+00:00 2026-06-12T15:09:31+00:00

I need a command code that increase the label name . I need to

  • 0

I need a command code that increase the label name.

I need to display in 10 (example) labels some texts.

Example:

label1.Text = "1";
label2.Text = "2";
label3.Text = "3";
label4.Text = "4";
label5.Text = "5";
label6.Text = "6";

I need to increase the number from label name (label1, label2, etc.) in a foreach where I will increase the variable i (i will be use in a structure like this label.Name = "label" + i.ToString();).

I hope that you understand what I want to say.

I try this but don’t work:

Label[] label = new Label[2];

int ii = 0;
foreach(...) // go through a list
{
                label[ii] = new Label();
                label[ii].Text = x.materie + tip + "\nsala " + x.sala;
                label[ii].Visible = true;
                label[ii].Location = new System.Drawing.Point(cX, cY);
                label[ii].SetBounds(cX, cY, 98, cH);
                label[ii].MinimumSize = new Size(98, cH);
                label[ii].MaximumSize = new Size(98, cH);

                ii++;
}
  • 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-12T15:09:32+00:00Added an answer on June 12, 2026 at 3:09 pm

    Assuming you have an array of Label controls, label, you can do the following:

    int i = 1;
    
    for (int i = 1; i < label.Length; i++)
    {
        lbl.ID = String.Format("label{0}", i.ToString());
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have some java code that work on the command line, and need to
I need a few lines of Java code that run a command x percent
I am running a shell command from Java code using ProcessBuilder.start() I need a
I need to automate the following command cmd=yes | vgremove <vgname> whenever I code
I need a shell command or script that converts a Unix timestamp to a
I need to locate a command line tool that would allow me to write
I've just inherited some C++ code that was written poorly with one cpp file
I am updating some older OpenCV code that was written in (I guess) an
I have this dicT in my code that contain some positions. position = ['712,352',
I need to know the command that I can print a sentence like the

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.