神啊!!!救救我吧!!关于 TCheckbox的问题?
各位大虾!!我有十个Checkbox1,Checkbo2,Checkbox3,Checkbox4..............
我想把Checkbox后面的1,2,3,4.........做为一个变量,然后给Checkbox赋值,最后分别来取他们的
Caption值。怎样写的语句啊,
我写的 if 'checkbox'+Inttostr(i).Checked=true then s:=s+'checkbox'+Inttostr(i).Caption;
运行不起啊,
那位大虾帮我就解决,必有重谢。
问题点数:40、回复次数:5Top
1 楼xixuemao(钱不是问题,问题是没钱)回复于 2005-11-01 13:49:27 得分 10
procedure TForm1.Button1Click(Sender: TObject);
var
i: integer;
begin
for i:= 1 to 10 do
(findcomponent('checkbox'+inttostr(i)) as TCheckBox).Checked:= true;
end;Top
2 楼konhon(优华)回复于 2005-11-01 13:49:30 得分 20
if Assigned(FindComponent('checkbox'+Inttostr(i))) then
if TCheckBox(FindComponent('checkbox'+Inttostr(i))).Checked then
// 應該這樣寫的Top
3 楼linzhengqun(风。我回来了)回复于 2005-11-01 13:53:55 得分 0
if 'checkbox'+Inttostr(i).Checked=true then s:=s+'checkbox'+Inttostr(i).Caption;
有时候真想骂骂人,怎么学Delphi的人会学出这个水平呢。Top
4 楼wdhans(wdhans)回复于 2005-11-01 13:57:20 得分 10
//从PANEL上找到相应的对象,可作参考
function GetObjectByName(ctrlName : string) : TObject;
var
i : Integer;
begin
Result := nil;
for i := 0 to Panel1.ControlCount -1 do
begin
if Panel1.Controls[i].Name = ctrlName then
begin
Result := Panel1.Controls[i];
break;
end;
end;
end;
//调用
(GetObjectByName('checkbox1') as TCheckBox).Checked := True ;Top
5 楼TNTTIAN999(哎呀呀)回复于 2005-11-01 14:48:12 得分 0
谢谢大家!!问题解决了,
也谢谢: linzhengqun(风。我回来了) 的提醒
我现在还是菜鸟
但我会努力的。Top




