Salut à tous. J'ai un PageControl dans lequel je je créé dynamiquement des TTabSheet avec dedans un GroupBox et des RadiosButton.
j'ai donc des variables globales définies comme cela:
tabsteps : array of TTabSheet;
gbs : array of TGroupBox;
rdb : array of array of TRadioButton;
La création des onglets et des TGroupBox se passe bien, mais lorsque je créé les radiobutton j'ai une erreur. Voici le code:
L'erreur viens donc de la création du TRadioButton, mais je ne vois pas pourquoi ça ne marches pas, si quelqu'un a une solution je suis preneur !
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 for I := 0 to high(rdb[index]) - 1 do rdb[index][i].Free; setlength(rdb[index],0); UIBQuery.SQL.Clear; UIBQuery.SQL.Text:='SELECT DISTINCT ' + fieldname + ' FROM "SEG$' + cmbtables.Text + '"'; UIBQuery.Open(); while not UIBQuery.Eof do begin i:=high(RDB[index]); if (i<0) then i:=0; setlength(RDB[index],i+1); showmessage(inttostr(i+1) + ' ' + inttostr(high(RDB[index]))); //obtiens 1 0 RDB[index][i-1]:=TRadioButton.create(gbs[index]); showmessage(inttostr(i+1) + ' ' + inttostr(high(RDB[index]))); //obtiens 1 12525455 RDB[index][i-1].Parent:=gbs[index]; showmessage(inttostr(i+1) + ' ' + inttostr(high(RDB[index]))); //obtiens 1 12525455 if not (high(RDB[index]) > 0) then //sauté car erreur avec le high RDB[index][0].Top :=20 else RDB[index][i-1].Top :=RDB[index][i-2].Top + 30; //ici élément non accessible donc erreur d'accès mémoire RDB[index][i-1].Height:=20; RDB[index][i-1].left:=20; RDB[index][i-1].width:=gbs[index].Width-40; RDB[index][i-1].Visible:=true; RDB[index][i-1].Caption:=UIBQuery.Fields.AsString[0]; if(UPPERCASE(fieldname)='"SEGMENTATION_NAME') then begin RDB[index][i-1].OnClick:=rdSegmentationclick; end; UIBQuery.Next; end; UIBQuery.Close();
Partager