title: check if an item has been selected in ListBox
body: <p>I want to check if an item has been selected in ListBox when user click on label <br>
  if i execute like that i got this error <code>list index out of bounds</code><br></p>
  
  <pre><code>procedure TfrMain.Label15Click(Sender: TObject);
  var
   saveDialog : TSaveDialog;
   FileContents: TStringStream;
   saveLine,Selected : String;
  begin
   saveDialog := TSaveDialog.Create(self);
   saveDialog.Title := 'Save your text or word file';
   saveDialog.InitialDir := GetCurrentDir;
   saveDialog.Filter := 'text file|*.txt';
   saveDialog.DefaultExt := 'txt';
   saveDialog.FilterIndex := 1;
  
   Selected := ListBox1.Items.Strings[ListBox1.ItemIndex]; 
  
   if Selected &lt;&gt; '' then
   begin
    if saveDialog.Execute then
    begin
     FileContents := TStringStream.Create('', TEncoding.UTF8);
     FileContents.LoadFromFile(ListBox1.Items.Strings[ListBox1.ItemIndex]);
     FileContents.SaveToFile(saveDialog.Filename);
     ShowMessage('File : '+saveDialog.FileName)
    end
   else ShowMessage('Save file was not succesful');
    saveDialog.Free;
   end;
  end;
  </code></pre>