samedi 21 mai 2022

Code for Alternating 2 Box Pattern using if statements

I am trying to find a code that helps to create a pattern of:

Picture of Checkered 2box pattern

but the number of rows and columns are custom. Currently this is the code i have but it doesnt apply properly for all values. (labelseat.backcolour=color.red , refers to the red boxes) Thank you for your time:D and this is in C#

                                count =0;
                                if (Row%2==0)
                                   {
                                    count+=1;
                                   
                                    if (count==3)
                                    {
                                        labelSeat.BackColor=Color.Red;
                                    }
                                    else if (count==4)
                                    {
                                        labelSeat.BackColor=Color.Red;
                                        count=0;
                                        
                                    }

                                }
                                if (Row%2==1)
                                {
                                    count+=1;
                                    
                                    if (count==1)
                                    {
                                        labelSeat.BackColor=Color.Red;
                                    }
                                    else if (count==2)
                                    {
                                        labelSeat.BackColor=Color.Red;

                                    
                                    }
                                    else if (count==4)
                                    {
                                        count=0;
                                    }
                                }

Aucun commentaire:

Enregistrer un commentaire