title: Invalidate only a single item in ListBox
body: <p>Is there anyway to only invalidate a single item in a <code>ListBox</code>? There seems to be no method of getting the rectangle of an item, or even if a specific item is visible (aside from calling <code>IndexFromPoint</code> for every pixel in the control / at least every pixel in one column).</p>
  
  <p>This is for C# WinForms (not WPF).</p>
  
  <p>More information about what I am trying to do:</p>
  
  <p>I have a <code>ListBox</code> with many items in it, and I want a set of "buttons" to appear on items that you hover over (such as a red X for remove). I have this working great,  except that on lists with 10 or more items, each time you hover over a new item it causes a visible redraw since I invalidate the entire control. The data is not changed, only the display is changed.</p>
  
  <p><strong>Edit: More Information and Previous Attempts</strong></p>
  
  <p>I already subclass <code>ListBox</code> and perform my drawing in <code>OnDrawItem</code> so protected methods of <code>ListBox</code> can be used.</p>
  
  <p>I have tried the following with varying levels of success. The variable <code>this</code> is the extended <code>ListBox</code>, <code>index</code> is the item to drawn over, <code>old_index</code> is the item previously being drawn over. </p>
  
  <pre><code>// Causes flicker of entire list, but works
  this.Invalidate();
  
  // Causes flicker of selected item, but works
  int sel_index = this.SelectedIndex;
  this.SelectedIndex = old_index;
  this.SelectedIndex = index;
  this.SelectedIndex = sel_index;
  
  // Does not work
  if (old_index &gt;= 0)
    this.RefreshItem(old_index);
  if (index &gt;= 0)
    this.RefreshItem(index);
  </code></pre>