怎么才能获得ListBox中当前选中项的值

解决方案 »

  1.   

    listbox.items.strings[listbox.items.itemindex]
      

  2.   

    没有这个listbox.items.strings[listbox.items.itemindex]
    应该是:listbox.items.strings[listbox.itemindex]
    不过出现错误:
    List index out of bounds (-1)
      

  3.   

    通过ListBox的Selected属性就能读出所有选中的项了。
      

  4.   

    通过listbox的itemindex属性
    如果没有选择itemindex=-1
    如果选择其中一条,返回的是当前的索引值!
      

  5.   

    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)
      

  6.   

    listbox.items.strings[listbox.itemindex]
    不过还要看你要做什么了,如果可以的话在将你的问题讲清楚一点。