Solved

Treenode is not showing the right imageindex

Posted on 2010-11-10
5
322 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Technology Partners: 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

Suggested Solutions

Many of us here at EE write code. Many of us write exceptional code; just as many of us write exception-prone code. As we all should know, exceptions are a mechanism for handling errors which are typically out of our control. From database errors, t…
This article is for Object-Oriented Programming (OOP) beginners. An Interface contains declarations of events, indexers, methods and/or properties. Any class which implements the Interface should provide the concrete implementation for each Inter…
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…
Attackers love to prey on accounts that have privileges. Reducing privileged accounts and protecting privileged accounts therefore is paramount. Users, groups, and service accounts need to be protected to help protect the entire Active Directory …

752 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