title: How do I associate a record with a TListBox item?
body: <p>I have one record type. I want to add the variable of that record type in TListbox and retrieve it on click event of TListbox. Is it possible? If yes then how?  </p>
  
  <p>I added it using</p>
  
  <pre><code>lstbox.AddItem(data,myrec);
  </code></pre>
  
  <p>It shows error of incompatible types. data is string and myrec is variable of MyRecord which I have created.  </p>
  
  <p>For adding:  </p>
  
  <pre><code>New(fptr1);
  ZeroMemory(fptr1,sizeof(fptr1^));
  fptr1^ := fptr^;
  lstboxLeft.AddItem(path,TObject(fptr1));
  </code></pre>
  
  <p>For retrieve:</p>
  
  <pre><code>fptr := PData(lstboxLeft.Items[lstboxLeft.ItemIndex]);
  </code></pre>