Treeview NodeClick 
Author Message
 Treeview NodeClick

VB6.
I would like a TreeView to respond the same on a programmatically invoked
Node_Click event as when it is invoked "by hand".

Any suggestions??

Thanks,
Carol.



Wed, 21 May 2003 03:00:00 GMT  
 Treeview NodeClick
That's not much to go on.  I assume that by "by hand" that you mean when the
mouse is clicked and programatically to mean that you call the Node_Click
event handler.  You call the Node_Click event and pass a valid "Node" object
(i.e. Node_Click(myNode) ).

If you provide more detail I will be happy to give a better answer.

--
Al Reid


Quote:
> VB6.
> I would like a TreeView to respond the same on a programmatically invoked
> Node_Click event as when it is invoked "by hand".

> Any suggestions??

> Thanks,
> Carol.



Fri, 23 May 2003 10:18:56 GMT  
 Treeview NodeClick
Thanks Al for your answer. I understood after sending the question that I
might be a bit confusing.

For those interested:

The problem I encountered had 2 origins:
1. By Clicking a Node it gets selected and Highlighted Blue. This didn't
happen when I passed a Node by code.
2. I was building an OCX and got a bit confused with the "internal"
Node_Click event and the Node_Click event of the interface.

Finally I managed to get things working. I didn't check "1", but still think
this is the case, i.e. one has to programmatically set the Highlight?

    Set tvwDB.DropHighlight = Nothing  ' deselecting any current Nodes
    Set tvwDB.DropHighlight = Node     ' selecting the Node

Carol.

Quote:
> That's not much to go on.  I assume that by "by hand" that you mean when
the
> mouse is clicked and programatically to mean that you call the Node_Click
> event handler.  You call the Node_Click event and pass a valid "Node"
object
> (i.e. Node_Click(myNode) ).

> If you provide more detail I will be happy to give a better answer.

> --
> Al Reid



Sat, 24 May 2003 07:01:55 GMT  
 Treeview NodeClick
Set tvwDB.SelectedItem=MyNode

Then call the NodeClick event as Albert stated,
tvwDB_NodeClick ( MyNode)

Setting the DropHighlight is more for drag & drop features I believe.
If you set the DropHighlight, you may encounter some strange behviour if
it's not set back to Nothing.
ie, a certain node will look like it is selected, user clicks on a new node,
new node looks "seleceted" while the mouse button is down, however when the
user lets go of the mouse, "selection" appears to go back to previous node.
(Although the SelectedItem property does reflect the new node, the
DropHighlight seems to override which node appears to be selected, hence the
name DropHighlight)

Anyway, hope I didn't confuse the issue but it may help you in your efforts.



Sun, 25 May 2003 03:00:00 GMT  
 Treeview NodeClick
Thanks Raughb for your contribution.

As I mentioned earlier I did solve my problem by using "DropHighlight", so
there is no problem anymore.
Just out of curiosity I tried your solution without using "Drophighlight"
but encountered the same problem.
My conclusion is:
- When one selects a node by clicking on it, the Node gets highlighted Blue
and it's data is activated.
- When one selects a node by code, the Node gets highlighted Grey and it's
data is activated.

Therefore to get the same behaviour of the Node by code as by hand you need
to use Drophighlight to make it blue !??

Am I wrong or am I right?

Carol.

P.S. I'm absolutely not an experienced programmer! Just fooling around with
VB for a while. Only 2 weeks ago "the quarter fell" regarding objects and
interfaces, as we say in Holland.



Sun, 25 May 2003 03:00:00 GMT  
 Treeview NodeClick

Quote:
> As I mentioned earlier I did solve my problem by using "DropHighlight", so
> there is no problem anymore.
> Just out of curiosity I tried your solution without using "Drophighlight"
> but encountered the same problem.

I tried to find your original posting of the problem but couldn't locate it.
What was it again?

Wasn't it changing the selection programatically? Which event(s) has/have
you put the DropHighlight in?
Just curious.
If you had a test project that demonstrated how you are using the
Drophighlight I would be most eager to look at it.

Quote:
> My conclusion is:
> - When one selects a node by clicking on it, the Node gets highlighted
Blue
> and it's data is activated.
> - When one selects a node by code, the Node gets highlighted Grey and it's
> data is activated.

The Grey colour may just mean the TreeView does not currently have focus
when the code was called.

Quote:
> Therefore to get the same behaviour of the Node by code as by hand you
need
> to use Drophighlight to make it blue !??

> Am I wrong or am I right?

I'm being facetious now; often when I ask myself that question it's either
both or neither.  ; )
I'm favoring "both" at present because 1. (right) you seem to have found a
solution to your problem so why am I still talking? and B. (wrong)  because
I have stubbornly resisted seeing your point of view. (Which could argueably
be said to be 'my' problem but that's another topic all together.)

Sorry. Too much coffee. Or not enough; one of the two.

Quote:
> Carol.

That's your name.

Quote:
> P.S. I'm absolutely not an experienced programmer! Just fooling around
with
> VB for a while. Only 2 weeks ago "the quarter fell" regarding objects and
> interfaces, as we say in Holland.

We're talking VB? What about my face and how did I get in Holland?

Ok, I'll be good now.  Seriously though, a test project would really help me
to see how you're doing the call; it may even teach me a few things I
initially avoided for reasons that were unjustified.



Mon, 26 May 2003 03:00:00 GMT  
 Treeview NodeClick
OK Raughb (btw how did your mother yell at you? without serious damaging her
voice?) you asked for it:

Method SelecteerNode() of ActiveX Control is called from Mainform:
This is in my terminology selecting a Node by code.
This routine is used when the user renames a Node.
The Index of the Node to be renamed is stored.
The RenameForm is used to retrieve the new name from the user and update the
Databasefield which holds the names of the Nodes.
After updating the database the TreeView OCX is refreshed / redrawn.
By doing this there is no selected Node anymore
The stored Index is used to reset the Highlight to the renamed Node by
invoking this routine, which is a method of the TreeViewOCX.

Public Sub SelecteerNode(Nindex As Long)
'
    Dim A As Node
    For Each A In tvwDB.Nodes
        '
        If A.Index = Nindex Then ' node found
            '
            A.Selected = True    ' Select the Node
            A.EnsureVisible      ' Unfold Tree
            A.Expanded = True    ' Show next level
            '
            Exit For ' Node found
           '
        End If
        '
    Next
     '
    tvwDB_NodeClick A ' Generate KLIK on the Serie.
    '
End Sub

' This Routine (internal in the OCX) is activated either by code or by hand.

Private Sub tvwDB_NodeClick(ByVal Node As Node)
    '
    ' Deselect current path (path is in bold)
    ' The treeview consists of 4 levels (Serie / Day / Race / Leg stored in
Tag of each Node)
    Dim CC As Node
    For Each CC In tvwDB.Nodes
        CC.Bold = False
    Next
    '
    m_ActNodeTag = tvwDB.SelectedItem.Tag
    m_ActNodeIndex = tvwDB.SelectedItem.Index
    m_ActNodeText = tvwDB.SelectedItem.Text

    Select Case tvwDB.SelectedItem.Tag

        Case "Serie"
            m_Serie = tvwDB.SelectedItem.Text
            m_Day = tvwDB.SelectedItem.Child.Text
            m_Race = tvwDB.SelectedItem.Child.Child.Text
            m_Leg = tvwDB.SelectedItem.Child.Child.Child.Text

            tvwDB.SelectedItem.Bold = True
            tvwDB.SelectedItem.Child.Bold = True
            tvwDB.SelectedItem.Child.Child.Bold = True
            tvwDB.SelectedItem.Child.Child.Child.Bold = True
            '
        Case "Day"

                ' some more code (left-out here)
            '
        Case "Race"

            Dim nodOpa As Node   ' ("Opa" is Granddaddy in dutch)
            Dim nodVader As Node

            Set nodVader = tvwDB.SelectedItem.Parent
            Set nodOpa = nodVader.Parent

            m_Serie = nodOpa.Text
            m_Day = tvwDB.SelectedItem.Parent.Text
            m_Race = tvwDB.SelectedItem.Text
            m_Leg = tvwDB.SelectedItem.Child.Text

            nodOpa.Bold = True
            tvwDB.SelectedItem.Parent.Bold = True
            tvwDB.SelectedItem.Bold = True
            tvwDB.SelectedItem.Child.Bold = True

        Case "Leg"

            ' some more code (left-out here)

        '
        End Select
'
' *******************************
' by leaving these 2 out the node becomes grey  when this routine is called
from code
' and blue when called by hand !!! This is what I call a difference between
calling from
' code and calling by hand. By using these 2 lines my problems (not of all
them) are solved.

    Set tvwDB.DropHighlight = Nothing
    Set tvwDB.DropHighlight = Node
    '
' ********************************

    RaiseEvent NodeIsGeklikt(Node)
    '
End Sub



Mon, 26 May 2003 03:00:00 GMT  
 
 [ 7 post ] 

 Relevant Pages 

1. Treeview nodeclick Problem

2. Cancel Treeview Nodeclick

3. Canceling Treeview nodeclick?

4. Cancel TreeView NodeClick

5. TreeView NodeClick Followup

6. (TreeView) NodeClick Event

7. treeview nodeclick event

8. Bug in Treeview NodeClick()?

9. Visual Basic TreeView Control - NodeClick Event

10. Generating NodeClick even in TreeView control

11. TreeView and NodeClick do not work

12. treeview control nodeclick event

 

 
Powered by phpBB® Forum Software