ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Treeview Question (https://www.excelbanter.com/excel-programming/365903-treeview-question.html)

vqthomf

Treeview Question
 
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

RB Smissaert

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




All times are GMT +1. The time now is 02:41 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com