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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T22:52:24+00:00 2026-06-15T22:52:24+00:00

I created four TextBox es (in this order: textBox1 , textBox2 ,…) and put

  • 0

I created four TextBoxes (in this order: textBox1, textBox2,…) and put them one below the other inside a GroupBox. Then I added the Click event:

private void button1_Click(object sender, EventArgs e)
{
    foreach (TextBox tb in groupBox1.Controls.OfType<TextBox>())
    {
        if (string.IsNullOrWhiteSpace(tb.Text))
        {
            Console.WriteLine(tb.Name);
        }
    }
}

When I run the program and click the Button (when all the TextBoxes are empty), this is the output I get:

textBox4

textBox3

textBox2

textBox1

Apparently the foreach loop iterated over the GroupBox controls in reverse order. I expected it to do it from textBox1 to textBox4 because this was the order they were created and put in the groupbox.

Why did the foreach loop in reverse? Just curious…

  • 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-15T22:52:26+00:00Added an answer on June 15, 2026 at 10:52 pm

    The controls are placed in order of the Z-order of the controls in the same parent container (top-most to bottom-most). How do you want to order them?

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I created a simple Converter to concatenate the text of four TextBoxes in my
I have created the SQL script below that creates four tables and inserts data
i created four drop down select lists in html and dynamically load them from
I am new in iphone...i have created toolbar with Four buttons...code is show below...I
I have created four different functions, like this: var normal = function() { return;
// I created four instance of movieclip on stage and named them t1_mc,t2_mc,t3_mc,t4_mc //
I just created a ComboBox in my VS2008. I put four items for it,
I created a databse with four tables in pgAdmin. It was coded in PostgreSQL.
I've created a simple Project model with four attributes: Project name:string description:text complete:boolean user_id:integer
An applet's life cycle has four methods: - init() when it is created -

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.