K
kent100
Unregistered / Unconfirmed
GUEST, unregistred user!
procedure TForm1.N3Click(Sender: TObject);
var
i:Integer;
s:String;
begin
s:='';
//for i := ListBox1.Items.Count - 1 downto 0 do
for i := 0 to ListBox1.Items.Count - 1 do
begin
if ListBox1.Selected then
begin
s:=s+ListBox1.Items;
listbox1.Items.Delete(i);
begin
with table1 do
if table1.Locate('jbdw',s,[]) then
begin
delete;
end;
break;
end;
end
else
showmessage('请选择左边列表中的一项');
break;
end;
end;
以上代码的意思是说当Listbox中没有一项选中时就出现提示
否则,删除选中的项。
但是我选中了Listbox中的一项但是还是提示我没选中,这是为何,程序老是执行到else后去,
而且我的if...else放在for循环里不是一个好办法,所以请大家帮我改改代码,谢谢!
var
i:Integer;
s:String;
begin
s:='';
//for i := ListBox1.Items.Count - 1 downto 0 do
for i := 0 to ListBox1.Items.Count - 1 do
begin
if ListBox1.Selected then
begin
s:=s+ListBox1.Items;
listbox1.Items.Delete(i);
begin
with table1 do
if table1.Locate('jbdw',s,[]) then
begin
delete;
end;
break;
end;
end
else
showmessage('请选择左边列表中的一项');
break;
end;
end;
以上代码的意思是说当Listbox中没有一项选中时就出现提示
否则,删除选中的项。
但是我选中了Listbox中的一项但是还是提示我没选中,这是为何,程序老是执行到else后去,
而且我的if...else放在for循环里不是一个好办法,所以请大家帮我改改代码,谢谢!