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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T00:58:33+00:00 2026-06-14T00:58:33+00:00

I have a C# form with some types of controls, i throught this code

  • 0

I have a C# form with some types of controls, i throught this code for loop all Labels and re-parent:

private void MakeAllLabelTrans(Control frm, Control parent)
{
    foreach (Control ctl in frm.Controls)
    {
        if (ctl is Label)
        {
            ctl.Parent = parent;
            // ctl.BackColor = Color.Transparent;
        }
        else if (ctl.HasChildren)
        {
            MakeAllLabelTrans(ctl, parent);
        }
    }
}

and call as: MakeAllLabelTrans(this, picBackground); in Form_Load event, but some label was missed (i have puted a messagebox in the loop body – it really not in the loop), but i don’t know why?

  • 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-14T00:58:34+00:00Added an answer on June 14, 2026 at 12:58 am

    You’re changing the collection while enumerating it. This leads to some items being skipped.

    You should rewrite this to first build a list of controls that will need to be reparented, and then reparent them in a second pass.

    • 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 some controls. (Actually, this is a sort of ongoing
I have a form in my asp.net mvc(C#) application which handles some dynamic controls.
I have a MouseEnter event which currently handles some custom controls on my form.
I have some *Type form classes and a forms.html.twig to customize form appearance. By
I apologize in advance, I am a PHP noob! I have form with some
I have a form with some ToolStrips, MenuStrips and a DataSet on it. Lately
I have next form and some ashx <form action=FileUpload.ashx method=POST enctype=multipart/form-data id=frmUpload> <input id=fileupload
I have a form with some input fields. I am using the tabStrip KendoUI
I have a form with some input fields and a little <div> to the
I have a form with some tags under it. When you click each tag

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.