Click here to Skip to main content
15,885,141 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have a WPF form that has a List Box populated with data from an XML file. The XML file contains an element called 'Status', which can be either 'a-current' or 'b-finished'. I have the code below to change the context menu header based on the 'Status' element content, but I can't seem to figure out how to get the click of the header to run a certain sub.
VB
Private Sub lstJobs_MouseRightButtonUp(sender As Object, e As MouseButtonEventArgs) Handles lstJobs.MouseRightButtonUp
        Dim o As ObjectDataProvider
        Dim j As Job = lstJobs.SelectedItem
        Dim cMenu As New ContextMenu, mi1 As New MenuItem

        If j.Status = "a-current" Then
            'MsgBox(j.Status)
            mi1.Header = ("Mark as _Finished")
        Else
            'MsgBox(j.Taken)
            mi1.Header = ("Mark as _Unfinished")
        End If

        cMenu.Items.Add(mi1)

        lstJobs.ContextMenu = (cMenu)

    End Sub

How do I process the selection of the context menu item?
Posted
Updated 15-May-15 3:24am
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900