I am using C# to get the usersuser's input of how many buttons to change the color of. The buttons are in rows that have 1-10 button in each. If the user enters 11 than, then the entire first row will be filled out and the first button on the second row will change color. I have figured out how to accommodate for different numbers the user might enter, but hoping to get some advice on how to code better with outwithout using a large ifif
, if elseif else
, statement. Here is my code
internal void ChangeTileColor(ConnectorData connectorData, int j)
{
int row = 0;
if (j < 10)
{
}
else if (j < 20)
{
j -= 10;
row++;
}
else if (j < 30)
{
j -= 20;
row += 2;
}
else if (j < 40)
{
j -= 30;
row += 3;
}
else if (j < 50)
{
j -= 40;
row += 4;
}
else if (j < 60)
{
j -= 50;
row += 5;
}
Button button = this.tableLayoutPanel1.GetControlFromPosition(j, row) as Button;
button.BackColor = Color.Lime;
}