Hello everyone,

I'm trying to implement windows form with data grid (or anything you say is better) which should represent a hierarchical data. This data are stored in a xml file which structure is as follows:

<elements>
     <element>
            <term>name of element</term>
            <subelements>
                    <caption>
                             <term>caption name</term>
                             <subelements>
                                    <caption>
                                           <term>caption 2 name</term>
                                     </caption>
                                      <position>
                                              <term>position name</term>
                                      </position>
                              </subelements>
                       </caption>
                       <position>
                              <term>position name</term>
                       </position>
              </subelements>
        </element>
        <element>
             .......
        </element>
</elements>

this means that element can consist of captions and positions, but captions can also have another captions and positions.

I would be very grateful if someone could tell me what is the best way to represent this data on windows form and how to do that.

The problem is that I can't use tree structure because I need to enter some data about this elements. Something like this:

Element         |    Start        |     End
element          01.01.2010    10.01.2010
  caption         01.01.2010    10.01.2010
     position     01.01.2010    10.01.2010

Recommended Answers

All 5 Replies

I'm trying to implement windows form with data grid (or anything you say is better) which should represent a hierarchical data. This data are stored in a xml file which structure is as follows:

I would be very grateful if someone could tell me what is the best way to represent this data on windows form and how to do that.

The problem is that I can't use tree structure because I need to enter some data about this elements.

You could make a data grid work for this, but the tree view is much more appropriate for hierarchical data. You can enter data in a tree view; have a look a the TreeView.LabelEdit property. It lets you allow the user to edit tree node labels using the TreeNode.BeginEdit method. The MSDN examples give an idea of how it's used.

You could make a data grid work for this, but the tree view is much more appropriate for hierarchical data. You can enter data in a tree view; have a look a the TreeView.LabelEdit property. It lets you allow the user to edit tree node labels using the TreeNode.BeginEdit method. The MSDN examples give an idea of how it's used.

Thank you for the answer. I will try this, but I need something more like MS Project. You have a part where you insert your tasks, and that should be a data grid view, and other parts where you insert the begining, end, duration and everything that has something to do with your task.
It should be a kind of gant chart where I have to fill in tasks, and user must be able to add other details.

Thank you!

... but I need something more like MS Project. ... It should be a kind of gant chart where I have to fill in tasks, and user must be able to add other details.

If you want to emulate Project, that's definitely a more DataGrid-like view. You can parse through the XML the same way you would to build a TreeView; just use the tree depth as a guide to indenting the first column of each row.

As for being able to expand and collapse rows in a DataGrid, the only thing I can think of right now is using parent/child tables--it doesn't feel quite right, but it would work.

The best thing would be a TreeView that also provides editable columns. Unfortunately, this isn't standard in the .NET Framework, but there are third-party controls out there. I don't know if the one I linked is right for you (and it's not free, if that's a requirement), but their screenshots look like the kind of thing you'll want.

Thank you Gusano. Actually I found this one. This controls have everything I need for this project.

Your answer was really useful, but I think that this controls are pretty good.

Thank you for your time.

Thank you Gusano. Actually I found this one. This controls have everything I need for this project.

They look good!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.