Tech Off Thread

5 posts

Forum Read Only

This forum has been made read only by the site admins. No new threads or comments can be added.

Tree view question

Back to Forum: Tech Off
  • User profile image
    manuelhjoao

    I’m building a class that will populate a tree view control with data that goes about three levels deep. My question is what data type is ideal to use in this situation? Keeping in mind that this data type will need to remain static because I am using static callback functions to enumerate window handles. This project I am working is something similar to the Spy++ utility that comes with visual studio. I’ve tried treenode arrays, and a few others but no such luck…  Anyone have any ideas? I can provide the few lines of code I have to tell you folks what exactly I am trying to accomplish here.

  • User profile image
    JohnAskew

    I am not sure what you are up to, but I like to create custom objects and assign them to the treenodes' Tag property.

    I think there are a few native datatypes that can fit in the Tag property for the treenodes, where you might store an integer or a pointer value.

    What are you trying to accomplish here?

  • User profile image
    manuelhjoao

    well first problem I have is this.

    public static TreeNode[] mytreeNodes;

    tells me is never assigned to and will always have a default value of null. So I guess I stuck because Im not sure how to intilize that array of treenodes

  • User profile image
    JohnAskew

    Go ahead and initialize the variable at its declaration. I would also suggest you use the TreeNodeCollection instead of an array. It only takes a bit of practice using Collections to see they are easier and better than arrays.

       TreeNodeCollection myNodes = new TreeNodeCollection();

  • User profile image
    manuelhjoao

    Yes in deed. I was thinking about using the Treenodes Collection. So many types to choose from... I thought about using just about everything. But I think Tree Nodes Collection is a good idea. Thanks again! Big Smile

Conversation locked

This conversation has been locked by the site admins. No new comments can be made.