|
 |
pro_vb_dotnet thread: Context Menu Help with treeview???
Message #1 by "Gabriel Brienza" <vbnetuk@y...> on Tue, 26 Feb 2002 14:43:43
|
|
Maybe I can help.
If Not ClickedNode Is Nothing Then
'user clicked on a node
Select Case ClickedNode.Tag
Case mcRootKey
With TvwContractsContextMenu.MenuItems
.Item(1).Enabled = False 'Disable edit
' something like this might work : -- I didn't try
it though
.item(1).nodes(1).enabled = False
' or maybe something like this:
for each node in .item(1).nodes
node.enabled = false
next node
' The problem here is that the state will be stored
in the nodes you disable -- so you are also
' obligated to enabled them when they apply....
' You can also use recursive techniques to walk
through all the children of a menu or node
' and set their enabled state as needed:
EnableMenu(.Item(1), False) ' this sets up the
walk and the following Sub completes the walk
'
the sub returns when there are no more children found.
Sub EnableMenu(ParentNode as menuItem , blnState as
boolean)
Dim node as MenuItem
ParentNode.enabled = blnState
For each node in ParentNode.nodes
EnableMenu(node, blnState)
next node
Return
This is not exactly what I think is needed but is close. See if this helps.
Richard Ainsley
rainsley@p...
----- Original Message -----
From: "Gabriel Brienza" <vbnetuk@y...>
To: "pro_VB_dotnet" <pro_vb_dotnet@p...>
Sent: Tuesday, February 26, 2002 1:31 PM
Subject: [pro_vb_dotnet] Re: Context Menu Help with treeview???
> >
> Hi Richard,
>
> Yes I put the following in the mousedown event of the treeview and I can
> now Enable and disable popupmenu the code I did is as follows:
>
> Private Sub tvwContracts_MouseDown(ByVal sender As Object, ByVal e As
> System.Windows.Forms.MouseEventArgs) Handles tvwContracts.MouseDown
>
> Dim ClickedNode As TreeNode = tvwContracts.GetNodeAt(e.X, e.Y)
>
> If Not ClickedNode Is Nothing Then
> 'user clicked on a node
> Select Case ClickedNode.Tag
> Case mcRootKey
> With TvwContractsContextMenu.MenuItems
> .Item(1).Enabled = False 'Disable edit
> .Item(2).Enabled = False 'Disable Delete
> End With
>
> Case mcCountryKey
> Case mcCityKey
> Case mcHotelKey
> Case Else
> Exit Sub
> End Select
> End If
> End Sub
>
> DO YOU KNOW HOW I CAN DISABLE THE SUBITEMS OF MY ITEM(1) IN THE
> CONTEXTMENU?
>
> Thanks
> Gabriel
$subst('Email.Unsub').
|
|
 |