CTreeCtrl selection problem
-
Hi, I have a problem with a CTreeCtrl in a FormView. When the view is initially shown and the user clicks a button to expand a branch of the tree, the item is expanded, but also the first item in the tree is selected. I don't want this behavior. Rather, I don't want an item to be selected until the user explicitly selects one by clicking it. How can I fix this? Thanks, Royce
-
Hi, I have a problem with a CTreeCtrl in a FormView. When the view is initially shown and the user clicks a button to expand a branch of the tree, the item is expanded, but also the first item in the tree is selected. I don't want this behavior. Rather, I don't want an item to be selected until the user explicitly selects one by clicking it. How can I fix this? Thanks, Royce
it should work: check clicking position, if clicking on button then move focus back to previous selected item.
-
it should work: check clicking position, if clicking on button then move focus back to previous selected item.
This is when the control is first displayed, so there is no previous item. Anyway, it appears that by default the first item is selected when the first expansion happens. It happens after the expansion is handled because there is no selection during the handling of the TVN_ITEMEXPANDED message. At any rate, I fixed the problem by adding a root item without any text. That root item gets selected, but because it has no text, it doesn't appear selected. Thanks for your help, Royce
-
it should work: check clicking position, if clicking on button then move focus back to previous selected item.
This is when the control is first displayed, so there is no previous item. Anyway, it appears that by default the first item is selected when the first expansion happens. It happens after the expansion is handled because there is no selection during the handling of the TVN_ITEMEXPANDED message. At any rate, I fixed the problem by adding a root item without any text. That root item gets selected, but because it has no text, it doesn't appear selected. Thanks for your help, Royce