title: List search results in a combobox
body: <p>I want to change our search as it is a bit hacky now.
  Currently it works like this:</p>
  
  <ol>
  <li>User enter a text in a textbox, for example <strong>Volvo</strong> and start searching.   </li>
  <li>This search with SQL all posts containing Volvo.   </li>
  <li>The result is a list with 2 columns, BoldID and DisplayValue.  </li>
  <li>BoldID is just an unique number to identify the object in database. </li>
  <li>DisplayValue is what the user see in the list of results.</li>
  <li>Each row in the resultset is identified with a row number in users list. The first with 1, the second with 2 and so on.</li>
  <li>There is also a limitation to only show max 99 hits by intention by looping the query in code. It is not good to have a query that returns many hits as it no meaning to have more in the users hit list. The search should be more specific in that case.</li>
  </ol>
  
  <p>The result list is displayed in a separate global window called rightpane. The hacky part is that if searching from a modal dialog then rightpane must be undocked from the main window to be able to pick a value with the mouse. We suspect this could be a reason that the application sometimes lock itself with the modal dialog behind the main window.</p>
  
  <p>After change it should work like this:</p>
  
  <p>The user enter text in a Combobox and start searching with SQL on demand like before. But the resultset is displayed in the combobox. So I only want to change the display if possible as there are a lot of old SQL queries that is in use and works fine now.</p>
  
  <p>We use Delphi 2007, Interbase 2009 and components from DevExpress. Yesterday I tried to connect a customdatasource to a combobox, but I realize this was not implemented yet. See <a href="https://stackoverflow.com/questions/3395739/how-to-use-a-tcxcustomdatasource-in-a-tcxextlookupcombobox">How to use a TcxCustomDataSource in a TcxExtLookupComboBox</a>. I want to use a custom datasource to implement row number and max number of hits. Se 6 and 7 in the list above.</p>
  
  <p>So now I see 2 options:</p>
  
  <ul>
  <li>Use a DB-aware combobox</li>
  <li>Use a textbox and attach a grid to it to display the resultset.</li>
  </ul>
  
  <p>The combobox is simpler because it is a whole component, but I don't know how to implement feature 6 and 7 from the list above.
  The textbox + grid give more freedom but require more work.</p>
  
  <p>I prefer the first option. The current problems is:</p>
  
  <ul>
  <li>I think Interbase SQL cannot restrict the amount of hits in the resultset. It must be done with code. How is this done with a DB-aware combobox ?</li>
  <li>How can I display row numbers in the resultset ?</li>
  </ul>
  
  <p><strong>Update 1:</strong>
  Requirement 7 is solved thanks to Marjan, thanks.
  As for 6 I think it is harder. Ideally I want it in SQL so I could extract an own column like <a href="http://www.openwinforms.com/row_number_to_sql_select.html" rel="nofollow noreferrer">Adding row no</a>. But Interbase don't support that.</p>