View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
RB Smissaert RB Smissaert is offline
external usenet poster
 
Posts: 2,452
Default Treeview Question

You could prevent users selecting another via the keyboard by doing this in
the KeyDown event:

if bSQLRunning then
KeyCode = 0
Exit Sub
end if

Preventing this is more difficult when the user uses the mouse and you will
need some code to keep track of the previously selected node and then
return to that. This couild be done with a private node variable that gets
set
in the node_click event.
So, you would get something like this:

Private oLastNode as Node

Private Sub TreeView1_NodeClick(ByVal Node As MSComctlLib.Node)

if bSQLRunning then
oLastNode.Selected = True
Exit Sub
else
Set oLastNode = TreeView1.SelectedItem
end if

Simplest would be to just set the Enabled property of the treeview
temporarily to False.


RBS


"vqthomf" wrote in message
...
Hi I am using a treeview to enable the user to run code that runs a sql
query, has anyone got any idea how to prevent the user selecting another
node
while the code is still running.
TIA
Charles