title: C#: Using .ico file with multiple images
body: <p>I'm trying to set the images in a TreeView in C#, from a .ico file containing two icons: a 32x32 version and a 16x16 version. The images are setting, but .Net is choosing the 32x32 version, and scaling it down (which looks terrible) instead of choosing the readily available 16x16 image.</p>
  
  <p>The relevant code:</p>
  
  <pre><code>ilTree.Images.Add(Properties.Resources.group);
  ilTree.Images.Add(Properties.Resources.single);
  ilTree.Images.Add(Properties.Resources.db);
  treeStored.ImageList = ilTree;
  </code></pre>
  
  <p>Where am I going wrong?</p>
  
  <hr>
  
  <p><strong>Answer:</strong></p>
  
  <p>There are two things you must do to get this to work. The first, as mentioned below, is to manually specify the correct size to the image list. The second is that you will also probably have to specify the color depth. MSDN states that:</p>
  
  <blockquote>
    <p>In the .NET Framework version 1.1 or later, the default is Depth8Bit.</p>
  </blockquote>
  
  <p>...however, that did not prevent ImageList from removing colors from my 8-bit icon. Upon close inspection, my icons (there were three) were: 4bit, 4bit, 8bit. The two 4 bit icons shared palettes, however the 8bit had a different one. In total, there were 257 colors between the icons. Despite the only slight overflow, .Net knocked it down to a mere <em>20</em> colors.</p>