Solved

Treenode is not showing the right imageindex

Posted on 2010-11-10
5
320 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 35

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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Latest thoughts on C# utilizing Mono on Linux vs .NET on Windows? 5 63
tableview is not updating 1 20
defining NULL or 0 10 44
How to repeat the data 4 17
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
This article aims to explain the working of CircularLogArchiver. This tool was designed to solve the buildup of log file in cases where systems do not support circular logging or where circular logging is not enabled
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

839 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