Context Menu and NTreeList


Author
Message
Vince McMullin
Vince McMullin
Junior Member (18 reputation)Junior Member (18 reputation)Junior Member (18 reputation)Junior Member (18 reputation)Junior Member (18 reputation)Junior Member (18 reputation)Junior Member (18 reputation)Junior Member (18 reputation)Junior Member (18 reputation)
Group: Forum Members
Posts: 18, Visits: 2
I would like to display a different context menu for each node collection on a NTreeList but I am having trouble figuring out how to do that exactly.

How do I check to see what the NTreeListNodeStringSubItem is equal to and then based on that display the proper context menu for the node collection?

Right now I have something that looks like this but it doesn't work:

Public Sub Quality_Click(ByVal sender As System.Object, ByVal e As MouseEventArgs) Handles NTreeList0.MouseClick

Dim pt As NPoint = New NPoint(e.Location)

Dim node As NTreeListNode = NTreeList0.ItemFromPoint(pt, True)


For i As Integer = 0 To node.SubItems.Count - 1


Dim r As Rectangle = node.SubItems(i).ViewBounds.ToRectangle()

If r.Contains(e.Location) Then


MessageBox.Show(node.SubItems(i).ToString)


Return

End If
Next


End Sub

Nevron Support
Nevron Support
Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)
Group: Administrators
Posts: 3.1K, Visits: 4.2K

Hello Vince,

You can try the following:

Private Sub NTreeList1_Click(ByVal sender As Object, ByVal e As MouseEventArgs) Handles NTreeList1.MouseClick
    Dim p As NPoint = New NPoint(e.Location)
    If e.Button = Windows.Forms.MouseButtons.Right Then
        Dim node As NTreeListNode = NTreeList1.ItemFromPoint(p)
        If node Is Nothing Then
            Return
        End If
        Dim clickedItem As NTreeListNodeSubItem = node.ResolveSubItem(ColumnFromPoint(p))
        If clickedItem Is Nothing Then
            Return
        End If
        Dim contextMenu As NContextMenu = New NContextMenu()
        ...
        contextMenu.Show(clickedItem, MousePosition)
    End If
End Sub

Private Function ColumnFromPoint(ByVal p As NPoint) As NTreeListColumn
    For i As Integer = 0 To NTreeList1.Columns.Count - 1
        Dim current As NTreeListColumn = NTreeList1.Columns(i)
        If current.ViewBounds.Contains(p) Then
            Return current
        End If
    Next
    Return Nothing
End Function



Best Regards,
Nevron Support Team


GO

Merge Selected

Merge into selected topic...



Merge into merge target...



Merge into a specific topic ID...




Similar Topics

Reading This Topic

Login

Explore
Messages
Mentions
Search