【发布时间】:2013-01-23 19:35:43
【问题描述】:
首先,我在 onselect 期间让 combobox1 填充 combobox2。我开始了很长的路,见下文。
procedure TFGetZoneDept.ComboBox1Select(Sender: TObject);
begin
Combobox2.Clear;
with Combobox1 do
begin
if text = '3' then
begin
with combobox2 do
begin
Add('Zone 3 depts');
Add('Zone 3 depts');
Add('Zone 3 depts');
Add('Zone 3 depts');
Add('Zone 3 depts');
Add('Zone 3 depts');
end; {with combobox2}
end; {If }
if text = '4' then
begin
with ComboBox2 do
begin
add('Zone 4 depts');
add('Zone 4 depts');
add('Zone 4 depts');
add('Zone 4 depts');
add('Zone 4 depts)';
end;{combobox2 with}
end;{IF}
if text ='1' then
begin
with ComboBox2 do
begin
add('Zone 1 depts');
add('Zone 1 depts');
add('Zone 1 depts');
add('Zone 1 depts');
add('Zone 1 depts');
add('Zone 1 depts');
end; {combobox2 with}
end; {IF}
if text ='2' then
begin
with ComboBox2 do
begin
add('Zone 2 depts');
add('Zone 2 depts');
add('Zone 2 depts');
add('Zone 2 depts');
add('Zone 2 depts');
add('Zone 2 depts');
end; {Combobox2 with}
end; {IF}
if text ='BoneYard' then
begin
with ComboBox2 do
begin
add('BoneYard depts');
add('BoneYard depts');
add('BoneYard depts');
add('BoneYard depts');
add('BoneYard depts');
add('BoneYard depts');
end; {combobox2 with}
end; {IF}
if text = 'Misc' then
begin
with ComboBox2 do
begin
add('Misc Depts');
add('Misc Depts');
add('Misc Depts');
add('Misc Depts');
add('Misc Depts');
add('Misc Depts');
end; {combobox2 with}
end; {IF}
end;{combobox1 with}
Combobox2.Enabled := true;
end;
我注意到你不能在里面使用一个 with 和另一个 with.. 或者我做错了。其次,我开始认为必须有更好的方法 :D 所以任何一个答案都可以。如何解决这个问题或以更好的方式做到这一点。
【问题讨论】:
-
啊啊啊啊!它燃烧!它buuurrrnssss!
-
这就是我讨厌
with声明的原因。
标签: delphi with-statement