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?
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.
Hello Michael,
ultraTree1.ActiveNode.LeftImages[0].ToString() will also give you the file name. I have created a sample and attached it. I have also attached the screen shot of the LeftImages[0] value I see while debugging.
Asma Developer Support EngineerInfragisticswww.infragistics.com/support
I am getting System.Drawing.Bitmap, not the imagelist keyname. What am I missing here? I am currently using 9.2, is this a feature you implemented on version 10?
Are you getting that in the sample attached here? Or only in your own code?
I tried this out in the sample project attached here and it worked for me. I was actually quite surprised by this, since typically, the ToString of a Bitmap simply returns the type name.
Either way, this has nothing to do with Infragistics code, this is all DotNet Framework code.
If, for whatever reason, you are not able to get the filename from the image, then there's really nothing else you can do about this. There's no support in DotNet for comparing two bitmaps or images.
So:
1) Your example is using v.10.1 where I am using 9.2.20092.2042. If the control version is not an issue, how is it that your example code is returning the image file name, whereas mine returns the type? I took your line of code, duplicated it in my program and got the type, as shown with the screenshot I attached.
2) Understanding that '.ToString()' is inherently coming from .NET and that it would return the type...if it the ToString on your system is returning the name of the file, does that mean you have the method overridden?
I am using the TAG of Left and Right images to replace my functionality but it would be a lot cleaner if I could just compare the image to something.
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.