我定义了一个public的 txtlb:array [1..10] of TLabel的数组,然后在一个function里面付它caption不同的值,而我那个function返回的是要整型,现在调用那个function没有问题,可是现在我在一个button的click事件里面想显示出它所有caption的值,但是发现全部为空,没有带出来,不知道怎样解决!
特此求救,大伙们帮帮忙^_^,急阿!
特此求救,大伙们帮帮忙^_^,急阿!
解决方案 »
- 图像重叠问题
- delphi转换webbrowser中的postdata为可识别数据
- 并发控制的问题(八百里加急)
- 请教DELPHI老手!!!关于子父窗体?
- 各位给我介绍几几个好点的树型(treeview)控件.
- 寻找图像显示控件的源代码
- 谁有早期的TeeChart5.ocx,文件大小为2,576,384,发行日期在2001-06-17号以前的,我这里有个crack软件,但是新下载的不行,所以重金寻求!!!
- 想念你 我心中的那个工程师
- 回调过程为何没任何反映
- 关于Delphi中使用Windows中自带的KODAK控件的一些问题
- 高手,对话框
- 请问谁有Programming MS IE 5这本电子书/?????!@?@@@@
var
content: array [0..100] of string;
ans: array [0..100] of string;
i,length,amount,j: integer;
step_x,step_y,seperator:integer;
AnswerFile:TextFile;
begin title:=TLabel.Create(lb);
title.Parent:=examPan;
title.Caption:='一.单选题(共40题,每题1.5分)';
title.Font.Style := [fsBold]; step_x := 10;
title.SetBounds(10,10,title.Width,title.Height);
step_y := 10+title.Height;
seperator := 30; AssignFile(AnswerFile,'standardAns.goc');
ReWrite(AnswerFile);
j:=index*40+1;
for i:=Low(TMyArr) to High(TMyArr) do
begin
query.SQL.Clear;
query.SQL.Add('select * from exam where ID='+inttostr(j)); try
query.Open;
if not query.Eof then
begin
content[i] := query.FieldbyName('Content').AsString;
// stansload[i] := query.FieldByName('standardans').AsSTring;
Writeln(AnswerFile,query.FieldByName('standardans').AsSTring);
ans[i] := query.FieldbyName('Selection').AsString;
txtlb[i] := TLabel.Create(lb);
anslb[i] := TLabel.Create(lb);
//selection part initial
sel[i] := TRadioGroup.Create(selecRad);
sel[i].Width := 150;
sel[i].Height := 30;
txtlb[i].Parent := examPan;
anslb[i].Parent := examPan;
sel[i].Parent := examPan;
txtlb[i].Caption := inttostr(i)+'. '+content[i];
txtlb[i].AutoSize := false;
anslb[i].Caption := ans[i];
sel[i].Columns := 4;
sel[i].Items.Clear;
sel[i].Items.Add('A');
sel[i].Items.Add('B');
sel[i].Items.Add('C');
sel[i].Items.Add('D');
sel[i].Tag := i;
sel[i].OnClick := MainF.Button1.OnClick; //setbounds
txtlb[i].SetBounds(step_x,step_y,txtlb[i].Width,txtlb[i].Height);
anslb[i].SetBounds(step_x+15,step_y+txtlb[i].Height,anslb[i].Width,anslb[i].Height);
sel[i].SetBounds(step_x+15,step_y+txtlb[i].Height+anslb[i].Height+20,sel[i].Width,sel[i].Height);
step_y := step_y+txtlb[i].Height+anslb[i].Height+sel[i].Height+10+20;
inc(j);
end
else
begin
showmessage('题库为空或不全');
break;
end; except
Showmessage('connect fail');
end;
query.Close;
end;
CloseFile(AnswerFile);
staticload:=step_y;end;
var txtlb: array of TLabel;
试试。
public
{ Public declarations }
txtlb:array [1..4] of TLabel;
procedure settxt;
end;var
Form1: TForm1;implementation{$R *.dfm}procedure TForm1.Button1Click(Sender: TObject);
begin
SetTxt;
showmessage(TxtLb[1].Caption);
end;procedure TForm1.settxt;
begin
TxtLb[1]:=TLabel.Create(self);
TxtLb[1].Caption:='11';
TxtLb[1].Parent:=Form1;
TxtLb[2]:=TLabel.Create(Self);
TxtLb[2].Caption:='22';
TxtLb[2].Parent:=Form1;
end;