Reputation: 105
I have a form containing multiple TreeView ActiveX controls with check boxes. Depending on the selected item in the first TreeView, I show different items in the other TreeViews.
I want to disable all the TreeViews if an uncheked item is selected in the first TreeView. To do so I check if the SelectedItem is checked in my update function. If not I set the Enabled property to false for all the TreeView except the first and exit. If it is checked I set the property back to true and update the TreeViews depending on the SelectedItem of the first TreeView.
It is working but my probleme is that when I set the Enabled property back to true, after it has been set to false, the TreeView is displayed in the top left corner. They stack in the corner so only the last one can be viewed.
I've search for a hint on how to fix this but had no luck. Any idea?
Upvotes: 0
Views: 922
Reputation: 13
For future searchers:
I also had an issue with a TreeView jumping to the top left. In my case, I had a sub-report that was updated as well, and everything was fine until I clicked on the TreeView. Once I did, the view jumped to the top left.
Here's what I did to fix it:
Private Sub MyTree_GotFocus()
Me.MyTree.Top = Me.MyTree.Top
Me.MyTree.Left = Me.MyTree.Left
End Sub
Even though it just set the properties equal to their current values, updating the values re-anchored the element.
You could most likely just add those lines after whatever triggers the jump.
Me.MyTree.Enabled = True
Me.MyTree.Top = Me.MyTree.Top
Me.MyTree.Left = Me.MyTree.Left
Upvotes: 1
Reputation: 1
I had a similar problem, the tree view would move when I switched from one tab to another. The only way I could get it to stop doing that was to put the TreeView control in its own sub-form (nothing in it but the TreeView control, and place that sub-form on the main form.
Upvotes: 0