NTreeViewEx - Cancel expand/collapse


https://www.nevron.com/Forum/Topic7461.aspx
Print Topic | Close Window

By Imanol Yurrebaso - 11 Years Ago
Hello,

In my NTreeViewEx, I capture the double click event and perform a certain operation with the text of that node. Additionally, following the behaviour of the NTreeViewEx, the node will collapse or expand depending on the previous state. I would like to avoid that behaviour, but still allowing the user to expand or collapse the nodes by using the +/- symbol.

I managed to capture the collapsing/collapsed/expanding/expanded events with the ItemNotify event, but I cannot find the way of cancelling the action. Any ideas?

PS: as I asked some questions here already and received good replies, I would like to thank the wonderful work of the Nevron Support Team .
By Nevron Support - 11 Years Ago
Hi Imanol,

Try to handle ItemNotify event as in following example code:

bool m_Clicked;

      void nTreeViewEx1_ItemNotify(object sender, NLightUIItemNotifyData data)
      {
         if (data.NotifyCode == NTreeViewEx.ItemLabelClickNotifyCode)
         {
            m_Clicked = true;
         }
                  
         if (data.NotifyCode == NTreeViewEx.NodeExpandingNotifyCode || data.NotifyCode == NTreeViewEx.NodeCollapsingNotifyCode)
         {
            if (m_Clicked)
            {
               data.Cancel = true;
               m_Clicked = false;
            }            
         }         
      }
By Imanol Yurrebaso - 11 Years Ago
Thanks, I managed to use that in my code .