I wouldn't have thought it was possible to do exactly what you want, in the way you want. Here's why:
When you add an Icon to the ImageList, it is first converted to a bitmap, which is a whole new object with a whole new handle. Because of this, the handle of the Icon you added to the ImageList initally will never equal the handle of the corresponding image in the ImageList. They are different objects.
If you want to be able to marry up the original icon with an item in the list at a later date I would suggest using the overload of ImageList.Add that allows you to add a key. You could even use the original handle as a key. See this following example.
- Icon icon = new Icon(); // Construct your icon here
-
IntPtr p1 = icon.Handle;
-
string key = p1.ToString();
-
imageList1.Images.Add(key, icon);
-
You can then find this image later using:
- IntPtr p1 = icon.Handle;
-
string key = p1.ToString();
-
Image i = imageList1.Images[key];