1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Have issue to populate treeview using dictionary!?

Discussion in 'C, C++, C#' started by sandrine10, Dec 8, 2013.

  1. sandrine10

    sandrine10 Power Member

    Joined:
    Apr 14, 2010
    Messages:
    642
    Likes Received:
    65
    Gender:
    Female
    Location:
    FreeLand
    Hi guys,

    Anyone can help me to populate treeview using dictionary please!here is the code i used:
    private void BuildLocationTree()
    {
    foreach (Country country in Locationclass.locations)
    {
    TreeNode node = this.locationTreeView.Nodes.Add(country.name);
    if (this.treeViewConf.ContainsKey(country.name))
    {
    node.Checked = true;
    }
    foreach (City city in country.citylist)
    {
    TreeNode node2 = node.Nodes.Add(city.name);
    if (this.treeViewConf.ContainsKey(city.name))
    {
    node2.Checked = true;
    }
    }
    }
    }

    private Dictionary<string, string> treeViewConf = new Dictionary<string, string>();
     
  2. DarkPixel

    DarkPixel Jr. VIP Jr. VIP

    Joined:
    Oct 4, 2011
    Messages:
    1,347
    Likes Received:
    1,252
    Location:
    ↓↓↓↓
    Home Page:
    Hmm you should post this to stackoverflow, if you don't get any response from bhw members.
     
    • Thanks Thanks x 1
  3. botrockets

    botrockets Regular Member

    Joined:
    Mar 16, 2013
    Messages:
    336
    Likes Received:
    529
    Gender:
    Male
    Occupation:
    Software Developer
    Location:
    Mumbai, INDIA
    what you want to do is not clear...
     
  4. sandrine10

    sandrine10 Power Member

    Joined:
    Apr 14, 2010
    Messages:
    642
    Likes Received:
    65
    Gender:
    Female
    Location:
    FreeLand
    botrockets Wanna load the treeview treenodes automatically from a dictionnary where i stored locations name.
     
  5. sandrine10

    sandrine10 Power Member

    Joined:
    Apr 14, 2010
    Messages:
    642
    Likes Received:
    65
    Gender:
    Female
    Location:
    FreeLand
    Is it possible to bind a treeview with dictionary. i want each Key in the ditionary to be a node and Value(which is a list) to be the items of the that node.
     
  6. sandrine10

    sandrine10 Power Member

    Joined:
    Apr 14, 2010
    Messages:
    642
    Likes Received:
    65
    Gender:
    Female
    Location:
    FreeLand
    Anybody......!!!