A TreeNode class has
Text Name Tag
I need to assign more values to a TreeNode class like float1, float2, ... float6.
How can I do this??? pls help.
Thx, Caslav
You can create a new class which inherits the TreeNode. For each value you want to store in the treenode, create a property for that value. When working with the Treeview, simply cast the TreeNode to your custom TreeNode class.
Example:
public class JobTreeNode : TreeNode {
private int intField1;
public int Field1 {
get {
return intField1;
}
set {
intField1 = value;
}
}
}
Usage (added after comments)
// Add the node
JobTreeNode CustomNode = new JobTreeNode();
CustomNode.Text = "Test";
CustomNode.Field1 = 10
treeView1.Nodes.add(CustomNode);
// SelectedNode
((CustomNode)(treeView1.SelectedNode)).Field1;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With