K
Kilroy Programmer
Is there a way to store a unique numeric identifier (say, for example,
an int) into a TreeNode, so that when the TreeNode is checked (since
CheckBoxes is enabled) the eventhandler AfterCheck() can examine the
responsible Node's identifier to see which TreeNode triggered the
event? Analyzing the Node's Text string is undesirable because it
would mean performing a string compare to a set of predefined strings.
This is slower and not easily maintained as the number of TreeNodes
increases.
Using GetHashCode() is undesirable because the resulting hash seems to
depend on the order in which the Nodes are checked.
I am hoping that after declaring a number of unique const ints in the
class constructor, I can later give each TreeNode its own unique
identifier as the TreeView is built. (Again, for easy lookup when
AfterCheck() is triggered). I need the solution to be persistent
across different instances of the program.
Does anyone have ideas on how to do this, or a different way to go
about what I'm trying to achieve? I've only been using C# for about a
week.
an int) into a TreeNode, so that when the TreeNode is checked (since
CheckBoxes is enabled) the eventhandler AfterCheck() can examine the
responsible Node's identifier to see which TreeNode triggered the
event? Analyzing the Node's Text string is undesirable because it
would mean performing a string compare to a set of predefined strings.
This is slower and not easily maintained as the number of TreeNodes
increases.
Using GetHashCode() is undesirable because the resulting hash seems to
depend on the order in which the Nodes are checked.
I am hoping that after declaring a number of unique const ints in the
class constructor, I can later give each TreeNode its own unique
identifier as the TreeView is built. (Again, for easy lookup when
AfterCheck() is triggered). I need the solution to be persistent
across different instances of the program.
Does anyone have ideas on how to do this, or a different way to go
about what I'm trying to achieve? I've only been using C# for about a
week.