Mehdi Soheili
Mehdi Soheili

Reputation: 17

C# TreeView limit dynamic child on each node

My Program

(my program)

In my project I want to limit creating some nodes.

The user can add or remove dynamic nodes and children. As in the above image, I have a parent called "screen" and a node called "program".

I have 3 objects called "videoObject","imageObject","textObject".

These are the rules I wish to apply:

  1. the objects can only be added to each "program" node.
  2. the objects don't have any children.
  3. each program node cannot have a program as a child.

I need bind a list to this treeview to store screen node programs and each program node child's properties.

How can I apply this rule to treeview?

Upvotes: 0

Views: 277

Answers (1)

Bernard Walters
Bernard Walters

Reputation: 391

I'm assuming you created a Model for this ? you could create a

private int _hierarchy = 0
public int Hierarchy
{
  get{return _hierarchy}
  set{_hierarchy = value}
}

before creation you check the higherarchy of the parent.

meaning if the hierarchy is 2, then you cant add a child to it.

Upvotes: 0

Related Questions