Profile Picture

Selected Item in Treelist

Posted By Ignacio Mendiguren 13 Years Ago
Author
Message
Ignacio Mendiguren
Posted 13 Years Ago
View Quick Profile
Junior Member

Junior Member (20 reputation)Junior Member (20 reputation)Junior Member (20 reputation)Junior Member (20 reputation)Junior Member (20 reputation)Junior Member (20 reputation)Junior Member (20 reputation)Junior Member (20 reputation)Junior Member (20 reputation)

Group: Forum Members
Last Active: 11 Years Ago
Posts: 20, Visits: 1
Hi,


I am new to Nevron components and am working with the treelist.
I wonder what is the way to get the selected item from the treelist?

Thanks,

IM

Nevron Support
Posted 13 Years Ago
View Quick Profile
Supreme Being

Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)

Group: Forum Members
Last Active: 14 hours ago
Posts: 3,054, Visits: 3,967

Hi Ignacio,

NTreeList control you can select the whole row which is represented by NTreeListNode.
Therefore you can get the selected node(s), not node's subitems.

You can obtain the selected node by SelectedNodes property.

Here is a small example:

//Filling NTreeList with some data.

NTreeListColumn column0 = new NTreeListColumn();
NTreeListColumn column1 = new NTreeListColumn();

nTreeList1.Columns.Add(column0);
nTreeList1.Columns.Add(column1);

for (int i = 0; i < 5; i++)
{
    NTreeListNode node = new NTreeListNode();
   
NTreeListNodeStringSubItem item0 = new NTreeListNodeStringSubItem("Item 0" + i.ToString());
    item0.Column = column0;

   
NTreeListNodeStringSubItem item1 = new NTreeListNodeStringSubItem("Item 1" + i.ToString());
    item1.Column = column1;

    node.SubItems.Add(item0);
    node.SubItems.Add(item1);

    nTreeList1.Nodes.Add(node);
}

After select some nodes you can get them as follows:

NTreeNode[] selectedNodes = nTreeList1.SelectedNodes;

Since, the array items are of type NTreeNode you should cast to NTreeListNode to get node's subitems.



Best Regards,
Nevron Support Team



Ignacio Mendiguren
Posted 13 Years Ago
View Quick Profile
Junior Member

Junior Member (20 reputation)Junior Member (20 reputation)Junior Member (20 reputation)Junior Member (20 reputation)Junior Member (20 reputation)Junior Member (20 reputation)Junior Member (20 reputation)Junior Member (20 reputation)Junior Member (20 reputation)

Group: Forum Members
Last Active: 11 Years Ago
Posts: 20, Visits: 1

Hi,

If I understood, using

NTreeNode[] selectedNodes = nTreeList1.SelectedNodes

I get all nodes selected, but how can I get the subitem selected?

Thanks

IM



Ignacio Mendiguren
Posted 13 Years Ago
View Quick Profile
Junior Member

Junior Member (20 reputation)Junior Member (20 reputation)Junior Member (20 reputation)Junior Member (20 reputation)Junior Member (20 reputation)Junior Member (20 reputation)Junior Member (20 reputation)Junior Member (20 reputation)Junior Member (20 reputation)

Group: Forum Members
Last Active: 11 Years Ago
Posts: 20, Visits: 1

Hi,

I found the answer. By doing

Dim a = DirectCast(selectedNodes(0), Nevron.UI.WinForm.Controls.NTreeListNode).SubItems(0).RawData

I get the value of the first column of the row selected.

Thanks and regards,

 

IM





Similar Topics


Reading This Topic