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?
Hi,
I think LeftImages are only supported in the Standard mode. If your tree is displaying as a grid or in OutlookExpress style, then you will need to create a column to display the images.
I am using the tree in a standard mode, and the images display fine.
What I did with the .NET trees was on a drag over event, look at what image the node had and do xyz. For instance, a command menu show event would hide certain tool items if the image was a file, but show others when it was a folder.
Like this:
if ((tempNode.LeftImages[0].Equals(ilProject.Images[9])) || (tempNode.LeftImages[0] == ilProject.Images[15]))
e.Effect =
DragDropEffects.Copy;
else
DragDropEffects.None;
This does not work though. ilProject is an imagelist I set to the trees imagelist property. If I have 100 nodes with the same image, are each pointing to the same image in memory, or are seprate images being created for every node?
Hello Michael,
You have to compare the Left Images as below code:
ultraTree1.ActiveNode.LeftImages[0] != imageList1.Images.Keys[0];
UltraTree1.ActiveNode.LeftImages[0] returns object of type string. All Nodes point to the same image in Memory, it will not create separate images.
Sincerely,Asma Developer Support EngineerInfragisticswww.infragistics.com/support
That does not work.
UltraTree1.ActiveNode.LeftImages[0] .ToString() == "System.Drawing.Bitmap"
imageList1.Images.Keys[0] = Filename of icon (ex: pic.png)
Comparing them with != or == does not produce an error, but does produce a warning regarding comparing an object to a string.
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.
Were you able to get your sample work? Did you try what Mike Saltzman suggested?
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