S
Sin Jeong-hun
For example, suppose if it is a TreeView. "AfterSelect" occurs both
for programmatic selection (TreeView.SelectedNode = something or
user selection (by mouse click or keyboard navigation). When the user
selects a node, then the program should change the model accordingly,
but when the model is changed by itself the program should change the
selected node to reflect the change. Not only for TreeView, but this
is generally the same for other UI controls. Another example is the
CheckedChanged of the CheckBox.
But sometimes I need to distinguish those two kinds. I have looked at
the source code of an application that my company releases to
customers, and the program simply(?) removed the eventhandler when it
needs to programatically change the UI control then added the
eventhandler again. The program itself had a bug that sometimes the
same eventhandler added twice due to some logical error. On the other
hand, I have used some sort of boolean flags for this. But neither
seems to be a clean solution.
What is the best practice to distinguish programmatic change from user
change for UI control states? As always, thank you for your
suggestions.
for programmatic selection (TreeView.SelectedNode = something or
user selection (by mouse click or keyboard navigation). When the user
selects a node, then the program should change the model accordingly,
but when the model is changed by itself the program should change the
selected node to reflect the change. Not only for TreeView, but this
is generally the same for other UI controls. Another example is the
CheckedChanged of the CheckBox.
But sometimes I need to distinguish those two kinds. I have looked at
the source code of an application that my company releases to
customers, and the program simply(?) removed the eventhandler when it
needs to programatically change the UI control then added the
eventhandler again. The program itself had a bug that sometimes the
same eventhandler added twice due to some logical error. On the other
hand, I have used some sort of boolean flags for this. But neither
seems to be a clean solution.
What is the best practice to distinguish programmatic change from user
change for UI control states? As always, thank you for your
suggestions.