+ Reply to Thread
Results 1 to 2 of 2

Thread: Updating context menu (always enabled entrys)

  1. #1
    Johnson is offline VB.NET Forum Fanatic Johnson is on a distinguished programming path ahead
    .NET Framework
    .NET 3.5 (VS 2008)
    Join Date
    Mar 2009
    Age
    20
    Posts
    134
    Reputation
    22

    Default Updating context menu (always enabled entrys)

    Hello, my list view has checked boxes, i want the entrys that are in cased in the if statements to be disabled if there is 1 or more entrys that have been checked.

    They are always enabled

    They are all disabled by default, and this even is called on context menu opening

    Code:
        ''' <summary>
        ''' Ensures the process manager context menu items reflect the selection/checked state.
        ''' </summary>
        Private Sub UpdateProcessManagerContextMenuItems()
            If Not (lvDisplayRunningProcesses.CheckedItems.Count > 0) Then
                Dim isItemSelected As Boolean = (lvDisplayRunningProcesses.SelectedItems.Count > 0)
                ProcessManagerMenuEndProcess.Enabled = isItemSelected
                ProcessManagerMenuCopyToClipboard.Enabled = isItemSelected
                ProcessManagerMenuProcessLibrary.Enabled = isItemSelected
                ProcessManagerMenuEditComment.Enabled = isItemSelected
            End If
            ProcessManagerMenuDeleteItem.Enabled = (lvDisplayRunningProcesses.CheckedItems.Count > 0)
            ProcessManagerMenuBlackList.Enabled = (lvDisplayRunningProcesses.CheckedItems.Count > 0)
        End Sub

  2. #2
    jmcilhinney's Avatar
    jmcilhinney is offline VB.NET Forum Moderator jmcilhinney has a reputation beyond repute jmcilhinney has a reputation beyond repute jmcilhinney has a reputation beyond repute jmcilhinney has a reputation beyond repute jmcilhinney has a reputation beyond repute jmcilhinney has a reputation beyond repute jmcilhinney has a reputation beyond repute jmcilhinney has a reputation beyond repute jmcilhinney has a reputation beyond repute jmcilhinney has a reputation beyond repute jmcilhinney has a reputation beyond repute
    .NET Framework
    .NET 3.5 (VS 2008)
    Join Date
    Aug 2004
    Location
    Sydney, Australia
    Age
    41
    Posts
    6,736
    Reputation
    653

    Default

    E.g.
    Code:
    Private Sub ContextMenuStrip1_Opening(ByVal sender As Object, _
                                          ByVal e As System.ComponentModel.CancelEventArgs) Handles ContextMenuStrip1.Opening
        Dim enabled As Boolean = (Me.ListView1.CheckedItems.Count = 0)
    
        Me.Item1ToolStripMenuItem.Enabled = enabled
        Me.Item3ToolStripMenuItem.Enabled = enabled
    End Sub

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

     

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts