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

  • Home
  • SEARCH
  • 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 7574917
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T16:33:20+00:00 2026-05-30T16:33:20+00:00

I want to look up a label at runtime, is this the correct way

  • 0

I want to look up a label at runtime, is this the correct way to do it?

Control[] control;
Label label;

control = this.Controls.Find(labelToChange, false);
label = (Label)control[0];

I couldn’t find a method that returns a single control, so I had to store it a collection and then retrieve the first one. It will always find a single item.

  • 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-30T16:33:21+00:00Added an answer on May 30, 2026 at 4:33 pm

    This is the correct method to use.

    The MSDN documentation doesn’t indicate why it returns a collection, but if you have the a control that encapsulates several sub controls and instantiate that several times you will end up with a collection of labels.

    So:

    1. If you can guarantee that there will only ever be one control visible at any one time your code is OK.
    2. If there could be more than one, then you need to loop over all the controls that are returned and either perform the same action on each or add some more code to work out which one you really want.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have code that I want to look like this: List<Type> Os; ... foreach
I have a link that I want to look like a button so I
I have an <li> element on the page that I want to look a
I have this simple textarea. When it's not selected, I want it to look
We have a GridView that bind to some data and it look like this:
I've been scouring the web for a way to do this. I want to
I want to make a new widget javascript class [Label] it look like dijit.button.
Basically, I know that Label works for the basic string. But what I want
I have a WPF conundrum. I want some text to look like this: Enter
I want to look at a production binary and know which revision in 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.