Solved

Treeview problem

Posted on 2009-07-09
1
164 Views
Last Modified: 2012-05-07
I am having some troble.

I can get a treeview with A, B, C.......Z
Here under each of the letters I want my Contacts Last name get under correct Letter.
For example Andersson should be under A

I have managed to do a search for the contact and getting a list back with all that includes for example A.

My problem is I want it into the treeview. How do I do that?

A
   Andersson
   Andersen
    Albertsson

B
   Bengtsson
    Berntsson

and so on

Please advice me......some code would be great
private void button1_Click(object sender, EventArgs e)

        {

            Contact cust = new Contact();

            cust.FirstName = textBox1.Text;

            cust.LastName = textBox1.Text;

            contactManager.Contacts.Add(cust);
 
 
 

            listView1.Items.Add(contactManager.Contacts[0].FirstName);

            List<Contact> searchList = new List<Contact>();
 

            //Supress repainting

            treeView1.BeginUpdate();
 

            char outstr = ('A');

            

            TreeNode node;

            for (int i = 1; i < 27; i++)

            {

                node = treeView1.Nodes.Add(Convert.ToString(outstr));

                searchList = contactManager.FindALetterSearch(outstr);

                outstr +=  (char)(+1);

            }

            //resume repainting

            treeView1.EndUpdate();

        }

Open in new window

0
Comment
Question by:Mickeys
1 Comment
 
LVL 29

Accepted Solution

by:
Gautham Janardhan earned 500 total points
ID: 24820585

private void button1_Click(object sender, EventArgs e)

        {

            Contact cust = new Contact();

            cust.FirstName = textBox1.Text;

            cust.LastName = textBox1.Text;

            contactManager.Contacts.Add(cust);

 

 

 

            listView1.Items.Add(contactManager.Contacts[0].FirstName);

            List<Contact> searchList = new List<Contact>();

 

            //Supress repainting

            treeView1.BeginUpdate();

 

            char outstr = ('A');

            

            TreeNode node;

            for (int i = 1; i < 27; i++)

            {

                node = treeView1.Nodes.Add(Convert.ToString(outstr));

                searchList = contactManager.FindALetterSearch(outstr);

                for(int k=0;k<searchList.Count;k++)

                {

                     node.Nodes.Add(searchList[k].FirstName);

                }

                outstr +=  (char)(+1);

            }

            //resume repainting

            treeView1.EndUpdate();

        }

Open in new window

0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
index Out OF Range Exception error 4 53
In Notepad++ is there a way to find the set of characters displayed in the attached file? 4 36
Error on link 14 36
Entity Framework 7 27
We all know that functional code is the leg that any good program stands on when it comes right down to it, however, if your program lacks a good user interface your product may not have the appeal needed to keep your customers happy. This issue can…
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.
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…
Concerto provides fully managed cloud services and the expertise to provide an easy and reliable route to the cloud. Our best-in-class solutions help you address the toughest IT challenges, find new efficiencies and deliver the best application expe…

948 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

21 Experts available now in Live!

Get 1:1 Help Now