Bonjour,

Voilà je créer plusieurs onglets, je nomme celui : TabControl + I.
Dans mon code je veut appeller Tabcontrol5 ou tabcontrol6 etc.. Mais je ne peut car il me fait une erreur : Identificateur non déclaré -> ce qui est normal.

Je voudrais savoir comment faire pour déclarer mes objets au fur et à mesure que je construis mes onglets (Sachant que je ne sais pas combien d'onglet je peut avoir). C'est la première fois que je développe comme cela.

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
 
const
  TabCount = 10;
var
  I: Integer;
  TabControl: TcxTabSheet;
  TestGrid : TcxGrid;
  Lab : TLabel;
  ch : string;
begin
...
for i := 0 to TabCount - 1 do
  begin
    //Onglet
    ch := 'Test' + IntToStr(I);
    TabControl := TcxTabSheet.Create(self);
    with TabControl do
    begin
        PageControl := cxPageControl1;
        Name := 'TabControl' + IntToStr(I);
        pagecontrol.ActivePage := TabControl;
 
        Caption := 'Tab ' + IntToStr(I);
    end;
    //TcxGrid
    testgrid := TcxGrid.Create(self);
    with TestGrid do
    begin
       Parent := TabControl;
       Top := 50;
       Width := 100;
       Height := 50;
    end;
    //Label
    Lab := TLabel.Create(self);
    with Lab do
    begin
       Parent := TabControl;
       Top := 8;
       Width := 100;
       Height := 50;
       Caption := Ch;
    end;
  end;
  cxPageControl1.ActivePage := Tabcontrol5;
J'espère avoir été clair.
Merci pour votre aide
Valoji