View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
[email protected] baobob@my-deja.com is offline
external usenet poster
 
Posts: 100
Default TreeView node is Selected but grayed out--how set focus?

My UserForm has a TreeView. A node is selected, has blue background
color, and is fully alive.

But if I minimize the form (thanks to Bullen's FormFun) then restore
it, the node is still selected (.SelectedItem.Selected = True), but
it's grayed out and focus has gone somewhere else.

Pressing the Up/Down keys does nothing. But if I press TAB, focus then
jumps to the next control on the form. Pressing Shift-TAB then returns
me to the node AND its color and focus are happily restored.

So programmatically, how do I 1) force focus back on the node, or
better 2) prevent focus from going away UNLESS and until another node
is selected?

I've tried various things and they all fail, e.g.:

with TreeView
if .Enabled and .Visible and (.Nodes.Count 0) then

1) TreeView.SetFocus

2) SelectedItem.Selected = True

3) SelectedItem.Visible = False followed by ditto = True. (Fails
because, at least for me, .Visible is read-only at run-time).

4) SelectedItem.Checked = True followed by = False.

5) Moving focus away & back again with:

Set S = .SelectedItem
..Nodes.Item(S.Index - 1).Selected = True
S.Selected = True

6) UserForm.Repaint

....quack quack.

Thanks much.

***