Profile Picture

Context Menu and NTreeList

Posted By Vince McMullin 14 Years Ago
Author
Message
Nevron Support
Posted 14 Years Ago
View Quick Profile
Supreme Being

Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)

Group: Forum Members
Last Active: Yesterday @ 8:46 AM
Posts: 3,054, Visits: 4,012

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



Vince McMullin
Posted 14 Years Ago
View Quick Profile
Junior Member

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
Last Active: 7 Years Ago
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




Similar Topics


Reading This Topic