在我的程序(国际象棋)中,我需要生成许多具有特定背景颜色(黑色或白色)的 Tpanels。面板已创建,但尽管设置了颜色,但它们仍保持无色。
for i := 1 to 8 do
for j := 1 to 8 do
begin
CellArray[i,j]:= TPanel.Create(Chess);
CellArray[i,j].Parent := Chess;
CellArray[i,j].Left := 20+(i-1)*70;
CellArray[i,j].Top := 20+(j-1)*70;
CellArray[i,j].Width := 70;
CellArray[i,j].Height := 70;
CellArray[i,j].Tag := i*10+j;
if odd(i+j) then
CellArray[i,j].Color := clblack
else
CellArray[i,j].Color := clwhite;
end;