Click here to Skip to main content
15,887,027 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I need to sort chess board's numbers like this`
8
7
6
5
4
3
2
1

but in my case it sorted like this`
1
2
3
4
5
6
7
8
what's my mistake?

What I have tried:

for (int i = 8; i > 0; i--)
            {
                Label lab = new Label();
                lab.Text = i.ToString();
                lab.Font = new Font("Tahoma", 18);
                lab.Location = new Point(0, 50 * i);
                lab.Width = 50;
                lab.Height = 26;
                this.Controls.Add(lab);
            }
Posted
Updated 5-Mar-18 22:17pm

1 solution

Replace
Quote:
lab.Location = new Point(0, 50 * i);
With
lab.Location = new Point(0, 50 * (9-i));
 
Share this answer
 
Comments
Suren97 6-Mar-18 4:19am    
Thanks so much
CPallini 6-Mar-18 4:51am    
You are welcome.
Maciej Los 6-Mar-18 6:26am    
5ed!
CPallini 6-Mar-18 9:17am    
Thank you, Maciej.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900