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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T04:26:29+00:00 2026-05-29T04:26:29+00:00

I have Label controls in Panel controls that need to be updated. The Panel

  • 0

I have Label controls in Panel controls that need to be updated. The Panel and Label controls are dynamically created. Now I need to find a way to get the value of 1 Label in a Panel.

C# Code

            // Create Panel
            Panel newpanel = new Panel();
            newpanel.Name = "panel_" + reader.GetValue(0);
            newpanel.Size = new Size(200, 200);
            newpanel.BorderStyle = BorderStyle.FixedSingle;
            newpanel.Parent = FlowPanel;

            // Create Label
            Label newipaddress = new Label();
            newipaddress.Name = "lbl_ip_add";
            newipaddress.Text = reader.GetValue(3).ToString();
            newipaddress.Location = new Point(55, 175);
            newipaddress.Parent = newpanel;

-------------

foreach (Panel p in FlowPanel.Controls)
{
    string ip = !!! GET IP FROM LABEL !!!
    Ping pingSender = new Ping();
    IPAddress pingIP = IPAddress.Parse(ip);
    PingReply pingReply = pingSender.Send(pingIP);

    lbl_ping_1.Text = string.Format("Ping: {0}", pingReply.RoundtripTime.ToString());
    if ((int)pingReply.RoundtripTime < 150)
    {
        lbl_ping_1.BackColor = Color.Green;
    }
    else if ((int)pingReply.RoundtripTime < 200)
    {
        lbl_ping_1.BackColor = Color.Orange;
    }
    else
    {
        lbl_ping_1.BackColor = Color.Red;
    }
}

The string ip needs to get the IP from the Label. The IP is in string format that will be converted to the IP address as you can see.

How can I get the value of the dynamically created Label?

  • 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-29T04:26:32+00:00Added an answer on May 29, 2026 at 4:26 am

    GUI Tools like labels really shouldn’t hold the data, it should just show the data. So in your case, it would really be better to hold the label information in a local variable or dictionary.

    In either case, you can search your panel’s control collection for the label’s name (control key):

    string ip;
    if (p.Controls.ContainsKey("ipLabel")) {
      ip = p.Controls["ipLabel"].Text;
    }
    

    This assumes when you created your label, you named it “ipLabel”:

    Label ipLabel = new Label();
    ipLabel.Name = "ipLabel";
    

    Update:

    You also need to add the controls to the container using the Controls collection instead of setting the Parent of the control.

    Example:

    newpanel.Controls.Add(newipaddress);
    

    I would do this with the panel to the flowpanel control as well:

    FlowPanel.Controls.Add(newpanel);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

When I have many controls on a Form (i.e. Label, Button etc) that do
I have a series of controls, but mostly textboxes and labels that need to
The scenario...I have a list of dynamic hyperlink controls on an ajax panel that
I have some Label controls sitting on Panel controls on a Form. I want
I have a composite control that adds a TextBox and a Label control to
I have a repeater control that contains an ItemTemplate containing a databound label and
I have a few controls defined inside an update panel which are bound to
I have a label label1 in the middle left of a large custom panel
I have a panel that has lots of labels and checkboxes. I want to
i have a System.Windows.Forms.Panel control in a windows application that has many labels and

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.