ok im building the tree according to a level no [0-4] extracted from XMl fiel
as following
TreeNode tnMainNode = null;
TreeNode tnLevelOne = null;
TreeNode tnLevelTwo = null;
TreeNode tnLevelThree = null;
TreeNode tbLevelFour = null;
for(int iItem = 0 ; iItem < nItems ;iItem++)
{
if(levelNodes[iItem].InnerText.Equals("0"))
tnMainNode = tvTOC.Nodes.Add(descNodes[iItem].InnerText);
switch(levelNodes[iItem].InnerText)
{
case "1":
tnLevelOne = tnMainNode.Nodes.Add(descNodes[iItem].InnerText);
break;
case "2":
tnLevelTwo = tnLevelOne.Nodes.Add(descNodes[iItem].InnerText);
break;
case "3":
tnLevelThree = tnLevelTwo.Nodes.Add(descNodes[iItem].InnerText);
break;
case "4":
tbLevelFour = tnLevelThree.Nodes.Add(descNodes[iItem].InnerText);
break;
}
}
I created the custom node inherited from TreeNode and add my own data and
replace the TreeNode objects above with it to be
TreeNodeEx tnMainNode = null;
TreeNodeEx tnLevelOne = null;
TreeNodeEx tnLevelTwo = null;
TreeNodeEx tnLevelThree = null;
TreeNodeEx tbLevelFour = null;
but when add it return TreeNode when ..so cast it to TreeNodeEx...
exception said Specified cast is not valid...what's wrong?
"Carlos J. Quintero [VB MVP]" wrote:
You can create a TreeNodeEx class which inherits from TreeNode and which
contains additional properties and then you add instances of it to the
treeview. When a TreeNode is clicked, you cast back to TreeNodeEx and
retrieve the additional data.
--
Best regards,
Carlos J. Quintero
MZ-Tools: Productivity add-ins for Visual Studio .NET, VB6, VB5 and VBA
You can code, design and document much faster.
Free resources for add-in developers:
http://www.mztools.com
"Raed Sawalha" <Ra*********@discussions.microsoft.com> escribió en el
mensaje news:AA**********************************@microsof t.com...I have a treeView with nested Items, I need to set for each node in tree a
specific data like following
Root---
---Node1 (here i need to attach url for each item so when user
click
it display it in DHtmlDialog)
---Node2
---Node3
so my question how to set this data for each item?