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. Context Menu Owner

Context Menu Owner

Scheduled Pinned Locked Moved C#
6 Posts 3 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.
  • G Offline
    G Offline
    greekius
    wrote on last edited by
    #1

    Hi all at run time i add controls to form. i set controls contextmenu property to contextmenustrip1 whish has 3 sub menus. i wanna make something to control (like changing backcolor) when user click Menu1ToolStripMenuItem. i need like at below Private Sub Menu1ToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Menu1ToolStripMenuItem.Click sender) Menu1ToolStripMenuItem.Owner .ContextMenu .**attainedControl**.BackColor=red End Sub How could i find "Attained Control"

    L G 2 Replies Last reply
    0
    • G greekius

      Hi all at run time i add controls to form. i set controls contextmenu property to contextmenustrip1 whish has 3 sub menus. i wanna make something to control (like changing backcolor) when user click Menu1ToolStripMenuItem. i need like at below Private Sub Menu1ToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Menu1ToolStripMenuItem.Click sender) Menu1ToolStripMenuItem.Owner .ContextMenu .**attainedControl**.BackColor=red End Sub How could i find "Attained Control"

      L Offline
      L Offline
      Luc Pattyn
      wrote on last edited by
      #2

      Hi, the sender parameter contains the sending object, you should cast it to what you expect, here a menu item. :)

      Luc Pattyn [Forum Guidelines] [My Articles]


      This month's tips: - before you ask a question here, search CodeProject, then Google; - the quality and detail of your question reflects on the effectiveness of the help you are likely to get; - use PRE tags to preserve formatting when showing multi-line code snippets.


      G 1 Reply Last reply
      0
      • G greekius

        Hi all at run time i add controls to form. i set controls contextmenu property to contextmenustrip1 whish has 3 sub menus. i wanna make something to control (like changing backcolor) when user click Menu1ToolStripMenuItem. i need like at below Private Sub Menu1ToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Menu1ToolStripMenuItem.Click sender) Menu1ToolStripMenuItem.Owner .ContextMenu .**attainedControl**.BackColor=red End Sub How could i find "Attained Control"

        G Offline
        G Offline
        Giorgi Dalakishvili
        wrote on last edited by
        #3

        I guess you are looking for ContextMenuStrip..::.SourceControl Property[^]

        Giorgi Dalakishvili #region signature my articles #endregion

        G 1 Reply Last reply
        0
        • L Luc Pattyn

          Hi, the sender parameter contains the sending object, you should cast it to what you expect, here a menu item. :)

          Luc Pattyn [Forum Guidelines] [My Articles]


          This month's tips: - before you ask a question here, search CodeProject, then Google; - the quality and detail of your question reflects on the effectiveness of the help you are likely to get; - use PRE tags to preserve formatting when showing multi-line code snippets.


          G Offline
          G Offline
          greekius
          wrote on last edited by
          #4

          i think u got me wrong. i wanna catch which control has that context menu which button clicked.

          1 Reply Last reply
          0
          • G Giorgi Dalakishvili

            I guess you are looking for ContextMenuStrip..::.SourceControl Property[^]

            Giorgi Dalakishvili #region signature my articles #endregion

            G Offline
            G Offline
            greekius
            wrote on last edited by
            #5

            thank you

            G 1 Reply Last reply
            0
            • G greekius

              thank you

              G Offline
              G Offline
              Giorgi Dalakishvili
              wrote on last edited by
              #6

              Glad to help you :)

              Giorgi Dalakishvili #region signature my articles #endregion

              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