fpSpread1.ActiveSheet.Protect = true;
for (int i = 0; i < 28; i++)
{
for (int j = 0; j <18; j++)
{
if (array[i, j] == 1)
{
fpSpread1.ActiveSheet.Cells[i + 4, j + 3].Locked = false;
}
}
}
private int[,] array = new int[,] { {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 },
{1,1,1,1,1,1,1,1,1,1,1,1,0,2,1,0,2,0 },
{1,1,1,1,1,1,1,1,1,1,1,1,0,1,2,0,0,2 },
{3,3,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 },
{3,3,1,1,1,1,1,1,1,1,1,1,0,2,1,0,2,0 },
{3,3,1,1,1,1,1,1,1,1,1,1,0,1,2,0,0,2 },
{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 },
{3,3,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 },
{3,3,1,0,1,0,1,0,1,0,1,0,0,2,1,0,2,0 },
{3,3,1,0,1,0,1,0,1,0,1,0,0,1,2,0,0,2 },
{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 },
{1,0,1,0,1,0,1,0,1,0,1,0,0,2,1,0,2,0 },
{1,0,1,0,1,0,1,0,1,0,1,0,0,1,2,0,0,2 },
{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 },
{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 },
{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 },
{1,1,1,1,1,1,1,1,1,1,1,1,0,2,1,0,2,0 },
{1,1,1,1,1,1,1,1,1,1,1,1,0,1,2,0,0,2 },
{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 },
{1,1,1,1,1,1,1,1,1,1,1,1,0,2,1,0,2,0 },
{1,1,1,1,1,1,1,1,1,1,1,1,0,1,2,0,0,2 },
{3,3,3,3,3,3,3,3,0,0,0,0,0,0,0,0,0,0 },
{3,3,3,3,3,3,3,3,1,1,1,1,0,2,1,0,2,0 },
{3,3,3,3,3,3,3,3,1,1,1,1,0,1,2,0,0,2 },
{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 },
{1,1,1,1,1,1,1,1,1,1,1,1,0,2,1,0,2,0 },
{1,1,1,1,1,1,1,1,1,1,1,1,0,1,2,0,0,2 },
{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 }};
for (int i = 0; i < fpSpread1.ActiveSheet.RowCount; i++)
{
for (int j = 0; j < fpSpread1.ActiveSheet.ColumnCount; j++)
{
if (fpSpread1.ActiveSheet.Cells[i, j].Locked.Equals(false))
{
fpSpread1.ActiveSheet.Cells[i, j].BackColor = System.Drawing.Color.FromArgb(((System.Byte)(198)), ((System.Byte)(226)), ((System.Byte)(255)));
}
else
{
fpSpread1.ActiveSheet.Cells[i, j].BackColor = this.BackColor;
fpSpread1.ActiveSheet.Cells[i, j].CanFocus = false;
}
if (this.fpSpread1.ActiveSheet.Cells[i, j].Locked.Equals(false) && flag)
{
this.fpSpread1.ActiveSheet.SetActiveCell(i, j);
flag = false;
}
}
} |