Solved

aaaaa wont show in my Treeview. Why?

Posted on 2009-07-09
28
343 Views
Last Modified: 2012-05-07
I have the code below.

When I try to add "aaaaa" to my treeview it wont show up. Why? Everything else seem to work.
private void button1_Click(object sender, EventArgs e)
        {
            treeView1.Nodes.Clear();
            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++)
            {
                TreeNode node = treeView1.Nodes.Add(Convert.ToString(outstr));
                searchList = contactManager.FindALetterSearch(outstr);
                for (int j = 0; j < searchList.Count; j++)
                {
                    node.Nodes.Add(searchList[j].FirstName +" " +searchList[j].LastName);
                }
                outstr +=  (char)(+1);
            }
 
            textBox1.Text = "";
            //resume repainting
            treeView1.EndUpdate();
            
        }
 
-----------------------------------------------
 
 public List<Contact> FindALetterSearch(char letter)
        {            
            List<Contact> returnList = new List<Contact>();
           
            if (exists)
            {
                for (int i = 0; i < contact.Count; i++)
                {  
                    if (contact[i].LastName.ToLower().StartsWith(letter.ToString().ToLower()))
                    {
                        returnList.Add(contact[i]);
                    } //end if                                    
                } //end for
            } //end if
            
            return returnList;
        } //end Search

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
  • 15
  • 13
28 Comments
 
LVL 29

Expert Comment

by:Gautham Janardhan
ID: 24820665
does ur first node appear ?
 
0
 

Author Comment

by:Mickeys
ID: 24820692
everything appear.

A, B C......Z
if I add Andersson that will come in  BUT if I add aaaaa that wont show up
0
 

Author Comment

by:Mickeys
ID: 24820697
it seems to happen only when I add an a with an a after the first a. :-)

So "a"  will come up

but

"aa" wont come up

b will come up
bb will come up
0
Independent Software Vendors: 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!

 
LVL 29

Expert Comment

by:Gautham Janardhan
ID: 24820707
check whether the aaaa comes in the search list or not and change ur search function as shown below
public List<Contact> FindALetterSearch(char letter)
        {            
            List<Contact> returnList = new List<Contact>();
           
            if (exists)
            {
                returnList = contact.FindAll(c=>c.LastName.ToLower
                     ().StartsWith(letter.ToString().ToLower()));
            } //end if            
            return returnList;
        } //end Search

Open in new window

0
 

Author Comment

by:Mickeys
ID: 24820729
I have changed the code to your suggestion. It works the same. Not change.

the aaaa comes into the searchlist
0
 

Author Comment

by:Mickeys
ID: 24820777
sorry.......aaaa never goes into the searchlist. So something must be wrong with the contact.FindAll ???
0
 
LVL 29

Expert Comment

by:Gautham Janardhan
ID: 24820793
check what is the last name for 'aaaa' ?
0
 

Author Comment

by:Mickeys
ID: 24820804
well in the method FindALetterSearch

contacts has: Lastname aaaa
letter has: aaaaa

c => c.LastName.ToLower ().StartsWith    this I dont understand. No declaration on the c????
Anyway I cant see what that gets for value
0
 
LVL 29

Expert Comment

by:Gautham Janardhan
ID: 24820985

returnList = contact.FindAll(c=>c.LastName.Trim().ToLower
                     ().StartsWith(letter.ToString().ToLower()));

Open in new window

0
 

Author Comment

by:Mickeys
ID: 24821082
no the same. Nothing getsfound with aa or aaa or aaaa and so on
0
 
LVL 29

Expert Comment

by:Gautham Janardhan
ID: 24821237
can u try putting a trim for ur 'letter' variable also ?
0
 

Author Comment

by:Mickeys
ID: 24821317
nope. The same. :-(

 returnList = contact.FindAll(c => c.LastName.Trim().ToLower
                     ().StartsWith(letter.ToString().Trim().ToLower()));

Could you explain the c to me. Why dont you have to declare it? And what is c???
I am trying to debug it but dont get anything out of c
0
 

Author Comment

by:Mickeys
ID: 24821324
This one:
c.LastName.Trim().ToLower().StartsWith(letter.ToString().Trim().ToLower())
is false

c.LastName.Trim().ToLower()   = "aaa"
letter.ToString().Trim().ToLower() = "a"


0
 

Author Comment

by:Mickeys
ID: 24821332
If I add this:
c.LastName.Trim().ToLower().StartsWith("a")
is false

even if
c.LastName.Trim().ToLower()   = "aaa"
0
 
LVL 29

Expert Comment

by:Gautham Janardhan
ID: 24821420
c => this is a lamda expression  , the first part is its decalration. u sure that nothing gets added before the name , like some special character ?
0
 

Author Comment

by:Mickeys
ID: 24821468
This is directly from debug mode:

"aaaa"

Thats all there is. I think this is so strange
0
 
LVL 29

Expert Comment

by:Gautham Janardhan
ID: 24821519
can u use ToLowerInvariant instead of ToLower and see if any change is there ?
0
 

Author Comment

by:Mickeys
ID: 24821611
same thing. Nothing new.

 returnList = contact.FindAll(c => c.LastName.Trim().ToLowerInvariant().StartsWith(letter.ToString().Trim().ToLowerInvariant()));
0
 
LVL 29

Expert Comment

by:Gautham Janardhan
ID: 24821628
u sure that contact is coming in the 'contact' list ?
0
 
LVL 29

Expert Comment

by:Gautham Janardhan
ID: 24821631
if it's then this is totaly wiered i cant think of any reason why it;s not showing up in the search
0
 

Author Comment

by:Mickeys
ID: 24821772
I can send you my project in a zipped file to your mail if your intressted so are you able to debug.
0
 
LVL 29

Expert Comment

by:Gautham Janardhan
ID: 24821825
u can upload it here .. no need to send mail just rename the sip as jpg and upload
0
 

Author Comment

by:Mickeys
ID: 24821847
sorry. but it checks whats in the jpg file

The extension of one or more files in the archive is not in the list of allowed extensions: Contact/Contact/Address.cs
0
 
LVL 29

Expert Comment

by:Gautham Janardhan
ID: 24821911
can u try doc... ?
0
 

Author Comment

by:Mickeys
ID: 24822580
samething. That wont work.Sorry
0
 
LVL 29

Expert Comment

by:Gautham Janardhan
ID: 24822773
u can sent it to gauthampj at gmail.com
0
 

Author Comment

by:Mickeys
ID: 24822946
and u got mail :-)
0
 
LVL 29

Accepted Solution

by:
Gautham Janardhan earned 500 total points
ID: 24823766
yep..i'm going thru it
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying 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

In order to hide the "ugly" records selectors (triangles) in the rowheaders, here are some suggestions. Microsoft doesn't have a direct method/property to do it. You can only hide the rowheader column. First solution, the easy way The first sol…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …

622 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