1

TTreeViewDB テーブルから入力されるフォームに があります。リストには現在 22 項目があり、すべてにチェックボックスがあります。

は、事前に作成されたを持つTTreeView上にあり、他のすべての は動的に作成され、それらに が割り当てられます。TFormTPageControlTTabSheetTTabSheetTFrame

実行時に新しいを作成する現在のコードTTabSheetは次のようになります。

procedure TForm1.Button2Click(Sender: TObject);
var
  aTab: TTabSheet;
begin
  aTab := TTabSheet.create(self);
  aTab.Name := 'tabProduct_' + IntToStr(PageControl1.PageCount+1);
  aTab.PageControl := PageControl1;
  aTab.Caption := 'Product ' + IntToStr(aTab.PageIndex);
  LoadFrame(aTab.PageIndex);
end;

LoadFrame()手順のコードは次のとおりです。

procedure TForm1.LoadFrame(const index: integer);
var
  aClassName: string;
  aFrameClass : TFrameClass;
  I: Integer;
begin
  if index >= 50 then
    raise Exception.create('Max product count reached');
  if index >= Length(frames) then
    SetLength(frames, index+1);

  if assigned(frames[curIndex]) then frames[curIndex].hide;

  if not assigned(frames[index]) then
  begin
    if index = 0 then
      aClassname := 'TframeClient' // client
    else
      aClassname := 'TframeProdus'; // anything over pageindex 0 is a product
    aFrameClass := TFrameClass(GetClass(aClassname));
    if not assigned(aFrameClass) then
      raise exception.createfmt('Could not find class %s', [aClassname]);
    frames[index] := aFrameClass.Create(self);
    frames[index].name := 'myframe' + IntToStr(index); // unique name
    frames[index].parent := PageControl1.pages[index];
    frames[index].align := alClient;
  end;
  frames[index].show;
  curIndex := Index;
end;

その他の関連コード:

type
  TFrameArray = array of TFrame;

<...>

  private
    { Private declarations }
    curIndex: integer;
    frames: TFrameArray;
    procedure LoadFrame(const index: integer);
  public
    { Public declarations }
  end;

  TFrameClass = class of TFrame;

<...>

の項目 1、5、および 13 の横にあるチェックボックスをオンにするとしますTTreeView

でチェックインしたアイテムに対してのみとそのButton2を作成するようにコードを変更して確認するにはどうすればよいですか?TTabSheetTFrameTTreeView

4

1 に答える 1