Solved

Treeview problem

Posted on 2009-07-09
1
162 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
Comment Utility

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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

This article describes a simple method to resize a control at runtime.  It includes ready-to-use source code and a complete sample demonstration application.  We'll also talk about C# Extension Methods. Introduction In one of my applications…
Summary: Persistence is the capability of an application to store the state of objects and recover it when necessary. This article compares the two common types of serialization in aspects of data access, readability, and runtime cost. A ready-to…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

743 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

18 Experts available now in Live!

Get 1:1 Help Now