0

I have a treeview and I would like that the user will be able to select the last child only, in order to avoid problems when it is not selected an item, but a folder.

Has anybody any idea of if there exists such function for the treeview? I have not found it.

If there is not, a solution like checking if the last children has been selected or a directoy, I can try by myself. At this moment I would only know it that can be done setting any treeview feature.

faheem khan
  • 471
  • 1
  • 7
  • 33
David
  • 31
  • 1
  • 3

1 Answers1

0

It is not a treeview feature. But you can use the Tag property which allows the node to keep an object with it. (In your case a good way to know what type it is).

As stated in the comments, maybe you should review your design (altough I have no idea why you need such a restriction) it seems to me that preventing the user to click on some nodes is a bad approach.

You can programatically test if it is the last element with many approach like :

  • Declare Treeview Before_Select Event
  • Test if EventArgs e has child nodes
  • Allow or Cancel node select

Like I said this is one of many options.

phadaphunk
  • 12,785
  • 15
  • 73
  • 107