Einzelnen Beitrag anzeigen

c.Stetter

Registriert seit: 7. Nov 2007
20 Beiträge
 
#5

Re: Eigene klasse mit FindComponent

  Alt 14. Dez 2007, 07:00
Delphi-Quellcode:

...
  type
    TTurnierGruppen = class(TObject)
    private
      fGruppen,
      fSpieler : integer;
      fForm : TForm;
      fParent : TWinControl;
      fLeft, fTop : integer;
      aStringGrid : array of TAdvStringGrid;
      aTab : TTabSheet;
      aPageControl : TPageControl;
      aGruppenErgebnis : array of TAdvStringGrid;
...

  SetLength(aStringGrid, fGruppen);
  SetLength(aGruppenErgebnis, fGruppen);
  aPageControl := TPageControl.Create(nil);

  with aPageControl do
  begin
    Parent := fParent;
    Left := fLeft;
    Top := fTop;
    Width := 580;
    Height := 200;
    for i := 1 to fGruppen do
    begin
      aTab := TTabSheet.Create(nil);
      aTab.PageControl := aPageControl;
      aTab.Name := 'tab_Gruppe' + IntToStr(i);
      aTab.Caption := 'Gruppe ' + IntToStr(i);
      aStringGrid[j] := TAdvStringGrid.Create(nil);
      with aStringGrid[j] do
      begin
        Parent := aTab;
        Name := 'grd_Gruppe' + IntToStr(i);
        Left := 10;
        Top := 10;
        DefaultRowHeight := 20;
        DefaultColWidth := 60;
        Width := DefaultColWidth * 6;
        Height := 150;
        ColCount := fSpieler + 1;
        RowCount := fSpieler + 1;
        for k := 0 to fSpieler do
          Colors[k, k] := clBtnFace;
        OnClickCell := aGruppenClickCell;
        for m := 1 to ColCount - 1 do
          Cells[m, 0] := 'test' + IntToStr(m);
        for m := 1 to RowCount - 1 do
          Cells[0, m] := 'test' + IntToStr(m);
      end;

      aGruppenErgebnis[l] := TAdvStringGrid.Create(nil);
      with aGruppenErgebnis[l] do
      begin
        Parent := aTab ;
        Name := 'grd_GruppeErgebnis' + IntToStr(i);
        Left := aStringGrid[j].Width + 20;
        Top := 10;
        Width := 190;
        Height := 150;
        RowCount := fSpieler + 1;
        FixedRows := 1;
        ColCount := 5;
        ColWidths[0] := 60;
        ColWidths[1] := 30;
        ColWidths[2] := 30;
        ColWidths[3] := 30;
        ColWidths[4] := 30;

        DefaultRowHeight := 20;
        MergeCells(1, 0, 2, 1);
        MergeCells(3, 0, 2, 1);
        Cells[1,0] := 'Punkte';
        Cells[3,0] := 'Legs';
        for o := 1 to ColCount - 1 do
          for p := 1 to RowCount - 1 do
            cells[o, p] := '0';
      end;
    end;
  end;

...
und damit

    TAdvStringGrid(fForm.FindComponent('grd_GruppeErgebnis' + IntToStr(aPageControl.ActivePageIndex))).Cells[3, aCol] := IntToStr(veLegs); <-- hier springt er in den Quellcode rein. Ich hoffe, daß der Code soweit stimmt. Das generieren der Komponenten funktioniert einwandfrei, bis ich was eintragen will.
  Mit Zitat antworten Zitat