开发者

How to add columns dynamically to a TreeView

I'm fairly new to WPF and C#. I am developing a Tool, which 开发者_JAVA技巧reads data from a DB and puts it into a TreeView. My class model looks like this:

class Developer //Contains a name, a list of categories and some additional info
class Category //Contains a name, a list of products and some additional info
class Product //Contains a name and some additional info

For now, the tool displays all the Names in a hierarchical manner. This is done via two HierarchicalDataTemplates and a DataTemplate for the leafs.

My question now is, if anyone has an idea how to add some simple columns to the TreeView which should display some double values. The problem is, that the number of additional info(double values) is set through user input. So, if the user wants to display a range of 3 months, I need the TreeView to add 6 columns. (column count = months * 2)

Or maybe someone knows a wpf custom control which suits my needs and works under vs10 and .NET4.0.

Thanks in Advance


The basic TreeView control doesn't support columns, there are specialized controls for this. Those controls are often called TreeList or TreeListView, as it includes the features of a tree and of a ListView. There are some commercial controls (the Telerik RadTreeListView comes to mind ) and there are some free versions floating around (one is in the Windows SDK itself, another one can be found here).

I've used none of them, so I can't tell which one is best suited for your problems, but I would give the last one a try, as it looks as it would solve them.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜