当前位置:主页>销售管理软件> 列表

请问如何在循环获取ComboBox的Items内容时依次获 找速达财务软件破解版

进销存软件版1楼: 用for i:=0 to ComboBox1.items.count-1 do begin
Lstr:= ComboBox1.Items[i];//这么做循环完毕只能得到最后的item
可循环取得 ComboBox1的Items内容,但若我要使Edit1、Edit2……的Text分别显示对应的 ComboBox1的Items内容(比如1、2、3、……),请问该怎么做,最后剩那么点分了,还望大虾们不吝赐教啊。

2楼: pocedure SetData(SL:TStrings);
var
C:TComponent;
I:0
begin
for I:=0 to SL.Count-1 do
begin
C:=FindComponent(''edit''+IntToStr(i));
if Assigned(C) and C.InheritsFrom(TCustomEdit) then
TCustomEdit(C).Text:=SL[I]
end; 如速达财务软件破解版

3楼: procedure TForm1.Button1Click(Sender: TObject);
var
i:integer;
begin
for i:=0 to ComboBox1.items.count-1 do
Tedit(self.FindComponent(''edit''+inttostr(i+1))).text:=combobox1.Items[i]
end;

看懂了没? 前提是你有足够的edit, 并且命名也要edit1,edit2,edit3....的

4楼: procedure TForm1.Button1Click(Sender: TObject);


var
buttonarray:array of tbutton;
i:integer;
begin
i:=ComboBox1.Items.Count;
setlength(buttonarray,i);
for i:=0 to high(buttonarray) do
begin
buttonarray[i]:=tbutton.Create(form1);
buttonarray[i].Parent:=form1;
buttonarray[i].Left:=10;
buttonarray[i].Top:=(i+1)*10;
end;

for i:=0 to ComboBox1.Items.Count-1 do
begin
buttonarray[i].Caption:=ComboBox1.Items[i];
end;
end;

5楼: 谢谢,我去试试,好了马上就散分。

6楼: 用for i:=0 to ComboBox1.items.count-1 do begin
Lstr:= ComboBox1.Items[i];//这么做循环完毕只能得到最后的item
(每次循环,你赋值给Lstr,下次循环,会冲掉上次的赋值,所以循环完毕只能得到最后的item)

可循环取得 ComboBox1的Items内容,但若我要使Edit1、Edit2……的Text分别显示对应的 ComboBox1的Items内容(比如1、2、3、……),请问该怎么做,最后剩那么点分了,还望大虾们不吝赐教啊。

var
C:TComponent;
I:integer;
begin
for I:=0 to ComboBox1.items.Count-1 do
begin
C:=FindComponent(''edit''+IntToStr(i));
if Assigned(C) and (C is TEdit) then
(C as TEdit).Text:=ComboBox1.items.strings[I];
end;

进销存软件版7楼: to 铁盒子:您的做法我试了不行。。。提示错误
to shangshang:您的可行,但我的Edit要求是动态创建,不能事先定好。。
to sbzldlb:您的可行,正是我要的效果,太感谢了。
to royal1442:您的不能获得第一个item内容。。。
无论如何,感谢几位的帮助!!