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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T17:35:54+00:00 2026-06-06T17:35:54+00:00

In C# Winforms, while user first load the form, I get the input as

  • 0

In C# Winforms, while user first load the form, I get the input as a label ‘text’ into database by clicking on that label. After again if another user loads that form, I want to make that label disabled. How can I make that ?? This is the form sample

enter image description here

This is I’m tried:

  • If the user clicks more than one label I get the input string as ” E10,E9,E8,E7 etc., “
  • when another user loads the form I retrieve that string and split
    that by using “,” and stored it in a array

    But I don’t know how to make that label disable from the array. Help Please.

  • 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-06T17:35:56+00:00Added an answer on June 6, 2026 at 5:35 pm

    *strong text*1.- Do a loop in your array
    2.- Find the label using the name of the label (I’ve supossed that the name of the label is the same that the imput string you have in the array)
    3.- Disable the control

    foreach (string name in yourArray)
    {
       var matches = this.Controls.Find(name , true);
       ((Label) matches).Enable = False
    }
    

    I don’t have a compiler here right now, I hope it runs. Please, be understanding if not.

    Edit: Find a label by his text property:

    foreach(Control c in this.Controls)
    {
       if(c is Label)
       {
          if((Label) c).Text == "RequiredText")
          {
              // Do stuff here ;
          }
       }
    }
    

    Please, note that if the label is inside a panel, groupbox, or any content control you will have to udo contentControl.Controls instead of using ‘this’.

    Edit 2: Ok, This code works for me. I’ve a label with text “Sample”.

        var myarray = "E1,E2,Sample".Split(',');
    
        foreach (Control labelcontrol in this.Controls)
        {
            if (!(labelcontrol is Label)) continue;
            foreach (var text in myarray)
            {
                if (labelcontrol.Text == text)
                    labelcontrol.Enabled = false;
            }
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In Winforms you just have the Main function and that's what runs first, but
I have a winforms app that uses a UserControl. The user control's job is
While I realize that I could just show the form off-screen and hide it,
I have a Winforms application that the user uses to take a region based
I have a WinForms data entry form that will have upwards of 1500 questions.
I have an application (winforms) that downloads a file to user's temporary folder, then
In debug mode, while running the C# WinFOrms App, After I select the files
I am creating a small modal form that is used in Winforms application. It
I have some custom user controls in my .net winforms program that do not
My WinForms .NET 4 C# application records the desktop while the user interacts with

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.