我将ListBox的MultiSelect设置为False,那么ListBox.SelCount的结果怎么是-1,如果MultiSelect为True就得到了正确的结果。
帮助原文如下:
Read SelCount to determine the number of items that are currently selected. If the value of the MultiSelect property is false, SelCount is 0 or 1. If MultiSelect is true, the value of SelCount can be greater than 1 as well.

解决方案 »

  1.   

    对了,我的是Turbo Delphi Explorer
      

  2.   

    远问有解释,那就可能是BUG吧
      

  3.   

    帮助原文如下:
    Read SelCount to determine the number of items that are currently selected. If the value of the MultiSelect property is false, SelCount is 0 or 1. If MultiSelect is true, the value of SelCount can be greater than 1 as well.
    //////////////
    应该是BUG
      

  4.   

    function TCustomListBox.GetSelCount: Integer;
    begin
      Result := SendMessage(Handle, LB_GETSELCOUNT, 0, 0);
    end;
    //////////////
    调用这一句有问题..
      

  5.   

    upstairs,我也看了。好大一只臭虫。
      

  6.   

    不是BUG。
    见VCL Reference:
    Description SelCount is read-only. Use SelCount to find the number of selected items in the list box when the MultiSelect property is true.When the MultiSelect property is false, SelCount is always -1. 
      

  7.   

    之所以这样设计,是为了与Windows ListBox控制的举止一致。见Win32 SDK Reference:LB_GETSELCOUNTAn application sends an LB_GETSELCOUNT message to retrieve the total number of selected items in a multiple-selection list box. LB_GETSELCOUNT  
    wParam = 0; // not used; must be zero  
    lParam = 0; // not used; must be zero ParametersThis message has no parameters. Return ValuesThe return value is the count of selected items in the list box. If the list box is a single-selection list box, the return value is LB_ERR. 
      

  8.   

    应该是帮助文档的错误,不只这一处了,还有好多.有空的话,麻烦去qc.borland.com发布好了,这样应该后面的版本时会修正。
      

  9.   

    不知楼主用的什么版本的Delphi?
    在Delphi 7.01的帮助中已经没有你说的那段话。