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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T22:53:52+00:00 2026-06-03T22:53:52+00:00

I have some buttons on a Winform app, and using the following code have

  • 0

I have some buttons on a Winform app, and using the following code have changed their back colour and text.

List<Button> buttons = new List<Button>();

foreach (Button bt in panel1.Controls)
{
    if (bt is Button)
    {
        buttons.Add(bt);
    }

}

int btext = 1;
foreach (var button in buttons)
{

    button.Text = btext.ToString();
    button.BackColor = Color.White;
    btext++;
}

But on viewing the form when its run the button at the bottom right of the grid of buttons has the text “1” and the button at the top left of the grid has the text “36” displayed on it. I was hoping, and thought, that it should be the other way round. Why is it as it is and how do I change it please? Many thanks.

  • 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-03T22:53:53+00:00Added an answer on June 3, 2026 at 10:53 pm

    I think that the order in which controls are added to the panel1.Controls collection is relevant here. You can try to set the tab order for the buttons and then sort them by TabIndex property.

    foreach (var bt in panel1.Controls.OrderBy(c => c.TabIndex))
    {
        if (bt is Button) 
        {
            buttons.Add(bt);
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a winform with some buttons that are updated in an event handler.
I have some 10 buttons with image-text and hover states for each. What I
I have some 10 buttons with different names each.On selecting each button I need
I am trying to create a rich text editor. I have created some buttons
I have some options for pricing using radio buttons. When a user selects the
I have a winform app, which shows some information in time, every time it
I have a winform with some controls mostly buttons and textboxs. Now I have
I have a winform app and when i click on a button, i would
I have some buttons in an UIView. My problem is, that they get cut
I have some filter and one grid.And grid have some buttons like modify/edit.I am

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.