Nevron Forum

Click on Treelist Subitems

https://www.nevron.com/Forum/Topic3414.aspx

By Dieter Spiegel - Saturday, April 24, 2010

Is there an easy way in the treelist to get the subitem that the user clicked on? I can get the selected item, but have problems retrieving the subitem.

Thanks

Dieter
By Angel Chorbadzhiev - Monday, April 26, 2010

Hello Dieter,

You can get the subitem of NTreeList when the user click on it by the following way:

//Attach to MouseUp event

nTreeList1.MouseUp += new MouseEventHandler(nTreeList1_MouseUp);

...

void nTreeList1_MouseUp(object sender, MouseEventArgs e)

{

    NTreeListNode node = (NTreeListNode)nTreeList1.ItemFromPoint(new NPoint(e.Location));

    for (int i = 0; i < node.SubItems.Count; i++)

    {

        Rectangle r = node.SubItems[i].ViewBounds.ToRectangle();

        if (r.Contains(e.Location))

        {

            subItem = node.SubItems[i];

            return;

        }

    }

}

 

Regards,

Angel.