Solved

Treenode is not showing the right imageindex

Posted on 2010-11-10
5
318 Views
Last Modified: 2013-12-17
Hi,

I have this methode, and even thou I have specified
the right imageindex picture. It is not working:


            string NewText = "";
            if (InputBox.Show("New Folder", "Folder Name", ref NewText, validation) == DialogResult.OK)
            {
                TreeNode n2 = tvNotes.SelectedNode;
                n2.Nodes.Add(NewText);
                n2.ImageIndex = 2;               <==========
                n2.SelectedImageIndex = 3;  <==========

            }

Does anyone know the answer to that and is willing to help me?

Peter
0
Comment
Question by:peterkiers
5 Comments
 
LVL 7

Assisted Solution

by:mkobrin
mkobrin earned 100 total points
Comment Utility
You are not stating which images are being displayed.
Firstly the imagelist is 0 based so setting the imageindex to 2 will display the 3rd image, and 3 will show the 4th image.
Secondly, have you addigned the correct imagelist to your treeview?

Regards,
Mike
0
 
LVL 35

Expert Comment

by:Miguel Oz
Comment Utility
0
 
LVL 1

Author Comment

by:peterkiers
Comment Utility
"Firstly the imagelist is 0 based so setting the imageindex to 2 will display the 3rd image, and 3 will show the 4th image."   (I know)

"Secondly, have you addigned the correct imagelist to your treeview?" (Yes i did)

P.
0
 
LVL 10

Accepted Solution

by:
hosneylk earned 400 total points
Comment Utility
In case you're trying to add the image to the new node you should do this..
TreeNode n2 = tvNotes.SelectedNode;

TreeNode n3 = new TreeNode(NewText);

n3.ImageIndex = 2;

n3.SelectedImageIndex = 3;

n2.Nodes.Add(n3);

Open in new window

0
 
LVL 1

Author Comment

by:peterkiers
Comment Utility
Ahhh,perfect.

0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Introduction Hi all and welcome to my first article on Experts Exchange. A while ago, someone asked me if i could do some tutorials on object oriented programming. I decided to do them on C#. Now you may ask me, why's that? Well, one of the re…
For those of you who don't follow the news, or just happen to live under rocks, Microsoft Research released a beta SDK (http://www.microsoft.com/en-us/download/details.aspx?id=27876) for the Xbox 360 Kinect. If you don't know what a Kinect is (http:…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

728 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

8 Experts available now in Live!

Get 1:1 Help Now