Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. How can i track the menu item selection in C#

How can i track the menu item selection in C#

Scheduled Pinned Locked Moved C#
csharpc++question
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • C Offline
    C Offline
    Chiman1
    wrote on last edited by
    #1

    In C++ we have TrackPopupMenuEx() function to displays a shortcut menu at the specified location and tracks the selection of items on the shortcut menu. How can i track the menu item selection in C#. How can i archive similar functionality in C#. Sample application appreciated.

    D 1 Reply Last reply
    0
    • C Chiman1

      In C++ we have TrackPopupMenuEx() function to displays a shortcut menu at the specified location and tracks the selection of items on the shortcut menu. How can i track the menu item selection in C#. How can i archive similar functionality in C#. Sample application appreciated.

      D Offline
      D Offline
      Dan Mos
      wrote on last edited by
      #2

      In c# a context menu will be the similar one. It has a Checked property that you could use: treat the ClickEvent with something like this:

      ToolStripMenuItem ts = sender as ToolStripMenuItem;
      if (ts.Checked) { ts.Checked = false; }//if it was checked unchekc it
      else { ts.Checked = true; }//else check it

      Now you can use a foreach or something to retrive the checked items. Something like:

      foreach (ToolStripMenuItem item in contextMenuStrip1.Items)
      {
      if(item.Checked)//do stuff
      }

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups