Question about 4 lines of code

Posted on 2011-04-29
Last Modified: 2013-12-16

I am trying to figure out what these 4 lines do:

            foreach (DataRow row in DataClass.GetCategories().Rows)
                nodeParent = lstvFoodDB.Nodes.Add(row[ProductDatabase.CategoryField.Name].ToString()); <=======
                nodeParent.ImageIndex = 0;  <=======
                nodeParent.Tag = row;       <=======
                nodeParent.Nodes.Add("*");    <=======


Who can tell me what this code does?

Question by:peterkiers
    LVL 2

    Assisted Solution

    for each loop
    - a new lstvFoodDB Node is created using the CategoryFieldName
    - sets the ImageIndex to 0 (no image)
    - The nodes Tag property used to store a copy of the Row
    - It looks sub Node is created called "*"
    LVL 15

    Accepted Solution

    1 -  It add a new node to lstvFoodDB.nodes collection and save it on nodeParent.
          I asume lstvFoodDB is a TreeView.
          The TreeView is asociated with a ImageList.

    2 - Set the Image from ImageList to the node.

    3 - Stablish nodeParent .Tag to original Row.

    4 - It add a new child node to nodeParent with Text "*"


    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

    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.
    Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
    Internet Business Fax to Email Made Easy - With eFax Corporate (, you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
    Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

    728 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