Label.Caption:=SelectFoodListBox.Items.Strings[SelectFoodListBox.ItemIndex]; 是正确的,但是写在sql中, with CustomOrderQ do begin close; sql.clear; sql.Add('delete from 顾客定购 where 食品名称 ='''+SelectFoodListBox.Items.Strings[SelectFoodListBox.ItemIndex]+''''); ExecSQL; end; 确是不对的,错误为: EStringList Error,List index out of bounds (-1)
应该是:listbox.items.strings[listbox.itemindex]
不过出现错误:
List index out of bounds (-1)
如果没有选择itemindex=-1
如果选择其中一条,返回的是当前的索引值!
是正确的,但是写在sql中,
with CustomOrderQ do
begin
close;
sql.clear;
sql.Add('delete from 顾客定购 where 食品名称 ='''+SelectFoodListBox.Items.Strings[SelectFoodListBox.ItemIndex]+'''');
ExecSQL;
end;
确是不对的,错误为:
EStringList Error,List index out of bounds (-1)
不过还要看你要做什么了,如果可以的话在将你的问题讲清楚一点。