Solved

Treeview problem

Posted on 2009-07-09
1
170 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
[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
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

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

Article by: Najam
Having new technologies does not mean they will completely replace old components.  Recently I had to create WCF that will be called by VB6 component.  Here I will describe what steps one should follow while doing so, please feel free to post any qu…
Performance in games development is paramount: every microsecond counts to be able to do everything in less than 33ms (aiming at 16ms). C# foreach statement is one of the worst performance killers, and here I explain why.
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…
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…

730 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