vb.net Disable Treenode selection in Treeview

OFGemini
OFGemini used Ask the Experts™
on
I want to be able to select a treenode and during the treeview after select event I want to disable the user from selecting (highlighting) other treenodes.  I want to disable the user from selecting other treenodes because I am loading a tiff file during the after select event.  How can This be done?  I have tried adding and removing the event handlers for after and before selection, but other treenodes become highlighted while I am loading my tiff file.
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
The TreeView.BeforeSelect event gives you the option to cancel selection, you just have to know when to do it.

If you create the event handler like this you should be ok:

Private Sub TreeView1_BeforeSelect(sender as Object, e as TreeViewCancelEventArgs) _
     Handles TreeView1.BeforeSelect

     If (loading) Then e.Cancel = True
End Sub

Private Sub LoadingTiff()
     loading = True
     ' Do whatever you have to do to load the tiff
     loading = False
End Sub

Protected loading As Boolean = False

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial