title: TListView SelCount reporting the wrong number of items in a virtual list
body: <p>I need to enable or disable a button depending on whether at least a row is selected in the list or not.</p>
  
  <p>Below is the code to reproduce this issue. The list is populated using the OnData event and it allows multiple rows to be selected.</p>
  
  <p>I thought that I could use OnSelectItem to detect when the user changes the selection and then use the TListView SelCount function to detect the number of selected rows.</p>
  
  <p>The problem is that SelCount returns 0 when the user selects multiple rows. This works fine if the list is populated manually (i.e. not through the OnData event).</p>
  
  <p>Any ideas?</p>
  
  <p>Thanks</p>
  
  <p>Update: using the OnChange event instead seems to do the trick. Still it would be interesting to understand why SelCount returns 0 when multiple rows are selected (from within the SelectItem event).</p>
  
  <p>Another Update: I posted a test project: <a href="https://dl.dropboxusercontent.com/u/35370420/TestListView2.zip" rel="nofollow noreferrer">https://dl.dropboxusercontent.com/u/35370420/TestListView2.zip</a> as well as a screenshot: </p>
  
  <p><img src="https://i.stack.imgur.com/LWeq3.png" alt="enter image description here"> </p>
  
  <p>To reproduce this issue run the app, select Item1, then SHIFT+Click on Item2. The button is disabled. My intention was to enable the button dynamically as long as there is at least one item selected in the list. If there is no selected item the button is disabled.</p>
  
  <p>PAS file:</p>
  
  <pre><code>unit MainUnit;
  
  interface
  
  uses
    Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
    Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.ComCtrls, Vcl.StdCtrls;
  
  type
    TForm3 = class(TForm)
      ListView1: TListView;
      Button1: TButton;
      procedure FormCreate(Sender: TObject);
      procedure ListView1Data(Sender: TObject; Item: TListItem);
      procedure ListView1SelectItem(Sender: TObject; Item: TListItem; Selected: Boolean);
    private
      { Private declarations }
    public
      { Public declarations }
    end;
  
  var
    Form3: TForm3;
  
  implementation
  
  {$R *.dfm}
  
  procedure TForm3.FormCreate(Sender: TObject);
  begin
   ListView1.Items.Count := 5;
  end;
  
  procedure TForm3.ListView1Data(Sender: TObject; Item: TListItem);
  begin
    Item.Caption := String.Format('Item%d', [Item.Index]);
  end;
  
  procedure TForm3.ListView1SelectItem(Sender: TObject; Item: TListItem; Selected: Boolean);
  begin
   Button1.Enabled := ListView1.SelCount &gt; 0;
   OutputDebugString(pchar(String.Format('SelCount = %d', [ListView1.SelCount])));
  end;
  
  end.
  </code></pre>
  
  <p>Form:</p>
  
  <pre><code>object Form3: TForm3
    Left = 0
    Top = 0
    Caption = 'Form3'
    ClientHeight = 600
    ClientWidth = 952
    Color = clBtnFace
    DoubleBuffered = True
    Font.Charset = DEFAULT_CHARSET
    Font.Color = clWindowText
    Font.Height = -11
    Font.Name = 'Tahoma'
    Font.Style = []
    OldCreateOrder = False
    OnCreate = FormCreate
    PixelsPerInch = 96
    TextHeight = 13
    object ListView1: TListView
      Left = 168
      Top = 160
      Width = 250
      Height = 150
      Columns = &lt;
        item
          AutoSize = True
          Caption = 'Test'
        end&gt;
      HideSelection = False
      MultiSelect = True
      OwnerData = True
      TabOrder = 0
      ViewStyle = vsReport
      OnData = ListView1Data
      OnSelectItem = ListView1SelectItem
    end
    object Button1: TButton
      Left = 168
      Top = 120
      Width = 75
      Height = 25
      Caption = 'Some Action'
      Enabled = False
      TabOrder = 1
    end
  end
  </code></pre>