disable nodes on a treeview control 
Author Message
 disable nodes on a treeview control

Hi everybody,

Can anybody tell me if it is possible to disable nodes in a treeview (VB6 SP4) just like the MSDN help file does?

Many thanks,
Martin



Wed, 17 Nov 2004 19:37:31 GMT  
 disable nodes on a treeview control

Not directly. But you can change the colour of individual nodes (eg to grey), and use the tree MouseDown event to ignore any actions on the node.


  Hi everybody,

  Can anybody tell me if it is possible to disable nodes in a treeview (VB6 SP4) just like the MSDN help file does?

  Many thanks,
  Martin



Thu, 18 Nov 2004 07:26:59 GMT  
 disable nodes on a treeview control
Yes, basically there is no directly way since VB treeview control is just a
wrapper of treeview window, and so the ability of the wrapper does not
exceed the ability of treeview window.

However, if you search the newsgroup you will find that the question has
been answered several days ago. Ken Halter even wrote codes, for your
convenience, I list it below:

********************************************************************
You can try this code... it works.. but even with the LockWindowUpdate, it
flickers slightly. Can probably get better results by subclassing the
control.
Basically, it sets ForeColor = vbGrayText on every other Root node to
"Disabled" and checks for that in MouseDown..
'================
Option Explicit
Private Declare Function LockWindowUpdate _
   Lib "user32" (ByVal hwndLock As Long) As Long

Private Sub Form_Load()
   Dim i As Integer
   Dim j As Integer
   Dim nodX As Node

   With TreeView1
      .Checkboxes = True
      For i = 1 To 10
         Set nodX = .Nodes.Add(, , "R" & i, "R" & i)
         If i / 2 = Int(i / 2) Then
            nodX.ForeColor = vbGrayText
         End If
         For j = 1 To 5
            Set nodX = .Nodes.Add("R" & i, tvwChild _
            , "R" & i & "C" & j, "R" & i & "C" & j)
         Next
      Next
   End With
End Sub

Private Sub TreeView1_MouseDown(Button As Integer _
, Shift As Integer, x As Single, y As Single)
   Debug.Print "Form1:TreeView1_MouseDown", Timer
   Dim nodX As Node
   Set nodX = TreeView1.HitTest(x, y)
   If Not nodX Is Nothing Then
      If nodX.ForeColor = vbGrayText Then
         LockWindowUpdate Me.hWnd
         Debug.Print "Kicking it OUT!"
         TreeView1.Enabled = False
         DoEvents
         TreeView1.Enabled = True
         LockWindowUpdate 0
      End If
   End If
End Sub
'================
****************************************************************

Best Regards,

Alick Ye

This posting is provided "AS IS" with no warranties, and confers no rights.

--------------------

Newsgroups: microsoft.public.vb.controls
Subject: disable nodes on a treeview control
Lines: 46
MIME-Version: 1.0
Content-Type: multipart/alternative;
        boundary="----=_NextPart_000_0024_01C20971.7AB2FC60"
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 5.50.4807.1700
X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4807.1700
Organization: Ye 'Ol Disorganized NNTPCache groupie


X-Cache: nntpcache 2.4.0b5 (see http://www.nntpcache.org/)
Date: Sat, 1 Jun 2002 13:37:31 +0200
NNTP-Posting-Host: 195.81.38.20

X-Trace: psinet-eu-nl 1022931323 195.81.38.20 (Sat, 01 Jun 2002 12:35:23
BST)
NNTP-Posting-Date: Sat, 01 Jun 2002 12:35:23 BST
Path:
cpmsftngxa07!cpmsftngxa08!tkmsftngp01!newsfeed00.sul.t-online.de!t-online.de
!fr.usenet-edu.net!usenet-edu.net!fr.clara.net!heighliner.fr.clara.net!news-
x2.support.nl!psinet-eu-nl!not-for-mail
Xref: cpmsftngxa07 microsoft.public.vb.controls:131771
X-Tomcat-NG: microsoft.public.vb.controls

Hi everybody,
Can anybody tell me if it is possible to disable nodes in a treeview (VB6
SP4) just like the MSDN help file does?
Many thanks,
Martin



Fri, 19 Nov 2004 15:37:15 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. disabling node tooltips in TreeView control

2. TreeView disable node

3. Disabling Treeview Nodes

4. Disable node in treeview

5. TreeView Node enable/disable?

6. disabled nodes in a treeview

7. How to enable/disable treeview nodes

8. treeview and node disabled

9. Overlay 2 icons in ImageList control to assign to Treeview control node image

10. treeview node count not incrementing when adding new nodes

11. treeview - Move node, insert node

12. TreeView-Move Node Between Other Nodes?

 

 
Powered by phpBB® Forum Software