Hello:
I am using a imagelist with an ultratree. I am setting the leftimage to one of the imagelist items.
I want to compare if the leftimage of a node like this:
utvProjectView.ActiveNode.LeftImages[0] != ilProject.Images[13]
But, it does not seem to be working. How can I accomplish this?
I think my issue maybe that the imagelist has a .bmp's and .png's. I need to go back and test this again but it would make sense with what Mike said last post.
Hello Michael,
Were you able to get your sample work? Did you try what Mike Saltzman suggested?
Hi,
My apologies, I was mistaken. What happens here is that the LeftImages[0] is not returning an image, it's returning a string. This would not have worked in any older version of Visual Studio. The ImageList component didn't used to support keys for images, so that's where I got confused. Since it now supports strings, Visual studio apparently serialized the name (key) of the image, rather than the index into the ImageList like it used to do.
But the node object is still the same node object, regardless of whether you get it via the ActiveNode property or via the GetNodeFromPoint method. I tested out the code you have shown here and it works fine for me, I still get the name of the image.
If the ToString method in your case is returning the type name (System.Drawing.Bitmap), then the LeftImages indexer must be returning a Bitmap, rather than the name of the image in the ImageList.
If that's happening, then my guess is that somewhere in your code, you are changing the image and assigning a bitmap to the LeftImages collection instead of just assigning the key. For example, if you look at the Form1.Designer.cs file in the sample that Asma posted, you will see a line of code like this:
ultraTreeNode6.LeftImages.Add("administrator.png");
So this is adding the key of the image in the ImageList to the LeftImages collection.
But somewhere in your code, you must be assign an actual Bitmap or Image into the collection, instead of the key.
Ok, so here it is.
Yes, your project works, and yes it returns the file name. And on my project, if I add an AfterExpand or AfterSelect event..it works.
Except, that when you use the tree's GetNodeFromPoint method, but the returned Node does NOT have the name of the file, but tye type. You MUST have some control on the fact that the .ToString() of the LeftImage equates to the file name in on instance, then the type in the other.
Try this on your test code, and see what you get for the string result (example from the tree's drag over event).
string test = utvProjectView.ActiveNode.LeftImages[0].ToString();
Infragistics.Win.UltraWinTree.UltraTreeNode tempNode = utvProjectView.GetNodeFromPoint(utvProjectView.PointToClient(new Point(e.X,e.Y)));
test = tempNode.LeftImages[0].ToString();
When I run the sample with Infragistics Version 2009 Volume 2 (9.2) I get the same result. I get file name.
Instead of taking the line of code, did you run my sample with 9.2? You can use Project Upgrade Utility (Add in) to upgrade it to 9.2.
If my sample works in your machine with 9.2, there is something different in your code.
Asma Developer Support EngineerInfragisticswww.infragistics.com/support