请各位看一下下面这段代码,调试的时候发现程序根本就执行for循环,为什么会这样的?是不是这样写有问题?
  btnCount := 1;
  with TButton.Create(Self) do
  begin
    for I := 0 to ComponentCount-1 do
      if Components[I] is TButton then
        Inc(btnCount);
    Parent := Form1;
    Name := 'Button' + inttostr(btnCount);
    Top := Button1.Top + 10;
    Left := Button1.Left + 10;
    DragMode := dmAutomatic;
  end;