Solved

Treenode is not showing the right imageindex

Posted on 2010-11-10
5
321 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
ID: 34100387
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 36

Expert Comment

by:Miguel Oz
ID: 34100392
0
 
LVL 1

Author Comment

by:peterkiers
ID: 34100396
"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
ID: 34100446
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
ID: 34100456
Ahhh,perfect.

0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In my previous two articles we discussed Binary Serialization (http://www.experts-exchange.com/A_4362.html) and XML Serialization (http://www.experts-exchange.com/A_4425.html). In this article we will try to know more about SOAP (Simple Object Acces…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

713 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