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 to get which button of MainMenu control is pressed?

How to get which button of MainMenu control is pressed?

Scheduled Pinned Locked Moved C#
tutorialquestion
10 Posts 3 Posters 1 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
    choopie
    wrote on last edited by
    #1

    In some way I want to hide controls in my Windows form or show them depending on which MainMenu button (menuItem) is pressed? Thanks.

    Q A 2 Replies Last reply
    0
    • C choopie

      In some way I want to hide controls in my Windows form or show them depending on which MainMenu button (menuItem) is pressed? Thanks.

      Q Offline
      Q Offline
      quiteSmart
      wrote on last edited by
      #2

      hi you can get this by using the MainMenu_click event which is fired when any button is clicked. Inside the method of the MainMenu_click you can write a code that get which button is clicked depending on the index of each button. (the buttons in a Main Menu are indexed as an array element is indexed starting from 0) hope it helps. If you need any help contact me on MSN: jamilaboukhalil@hotmail.com Jamil Abou Khalil

      C 1 Reply Last reply
      0
      • Q quiteSmart

        hi you can get this by using the MainMenu_click event which is fired when any button is clicked. Inside the method of the MainMenu_click you can write a code that get which button is clicked depending on the index of each button. (the buttons in a Main Menu are indexed as an array element is indexed starting from 0) hope it helps. If you need any help contact me on MSN: jamilaboukhalil@hotmail.com Jamil Abou Khalil

        C Offline
        C Offline
        choopie
        wrote on last edited by
        #3

        I know that each button is presented by an index but the problem is that I want to place the code in timer1_tick event (sorry I didn't tell you). Jamil, have you got any idea how can I do that, or anyone else? Thanks

        Q 1 Reply Last reply
        0
        • C choopie

          I know that each button is presented by an index but the problem is that I want to place the code in timer1_tick event (sorry I didn't tell you). Jamil, have you got any idea how can I do that, or anyone else? Thanks

          Q Offline
          Q Offline
          quiteSmart
          wrote on last edited by
          #4

          hi sorry i have no idea about the timer1_click event but if you want tell me what does it do and for what control it is initiated. maybe i will be able to help best regards jamil abou khalil

          C 1 Reply Last reply
          0
          • Q quiteSmart

            hi sorry i have no idea about the timer1_click event but if you want tell me what does it do and for what control it is initiated. maybe i will be able to help best regards jamil abou khalil

            C Offline
            C Offline
            choopie
            wrote on last edited by
            #5

            :-O Well, I don't know about the click event too :). Ok, I talk about the only one event of the timer control timer1_tick. Sorry again :)). Can you help me?

            Q 1 Reply Last reply
            0
            • C choopie

              :-O Well, I don't know about the click event too :). Ok, I talk about the only one event of the timer control timer1_tick. Sorry again :)). Can you help me?

              Q Offline
              Q Offline
              quiteSmart
              wrote on last edited by
              #6

              hi i am not understanding what u want. first u said that u want to hide some controls when buttons are clicked or visa versa. That is solved by the click event of the button. and then u want to use the timer1_tick event which is fired as i saw on a given interval of time. i can't see what is the common between these information that you gave. best regards jamil abou khalil

              C 1 Reply Last reply
              0
              • Q quiteSmart

                hi i am not understanding what u want. first u said that u want to hide some controls when buttons are clicked or visa versa. That is solved by the click event of the button. and then u want to use the timer1_tick event which is fired as i saw on a given interval of time. i can't see what is the common between these information that you gave. best regards jamil abou khalil

                C Offline
                C Offline
                choopie
                wrote on last edited by
                #7

                I have a panel that changes it's size gradually by using the timer_tick event of the timer control. I want when I press a menu button this panel to show by encreasing it's size and show some of the controls. After that when I press the second menu button the panel hides (as it gradually decreases it's size to panel1.height = 0 and in the very next moment to increase again by showing the other controls). I thought I could take the text property of the buttons (menuItems) in a switch-case construction placed in the timer_tick event but it didn't work. I don't know if there is a simle way. It's a little complicated. Hope it is clear now what I want to do

                Q 1 Reply Last reply
                0
                • C choopie

                  In some way I want to hide controls in my Windows form or show them depending on which MainMenu button (menuItem) is pressed? Thanks.

                  A Offline
                  A Offline
                  aamironline
                  wrote on last edited by
                  #8

                  Create a global class level variable. On click of menu set the variable to clicked menu name. In the timer_tick event retrive the current menu from the variable.

                  M Aamir Maniar aamirOnline.com

                  C 1 Reply Last reply
                  0
                  • C choopie

                    I have a panel that changes it's size gradually by using the timer_tick event of the timer control. I want when I press a menu button this panel to show by encreasing it's size and show some of the controls. After that when I press the second menu button the panel hides (as it gradually decreases it's size to panel1.height = 0 and in the very next moment to increase again by showing the other controls). I thought I could take the text property of the buttons (menuItems) in a switch-case construction placed in the timer_tick event but it didn't work. I don't know if there is a simle way. It's a little complicated. Hope it is clear now what I want to do

                    Q Offline
                    Q Offline
                    quiteSmart
                    wrote on last edited by
                    #9

                    hi u should go to the first soulution that i gave to u; that is; using the button_click event. double click on the menu item and that event will write a function for you and then write a what u need inside it. i can't see another solution for that. best regards jamil abou khalil

                    1 Reply Last reply
                    0
                    • A aamironline

                      Create a global class level variable. On click of menu set the variable to clicked menu name. In the timer_tick event retrive the current menu from the variable.

                      M Aamir Maniar aamirOnline.com

                      C Offline
                      C Offline
                      choopie
                      wrote on last edited by
                      #10

                      Hi, thanks both of you. Now I tryed to solve the problem with a global class variable and it works. It just needs a little fixing. I'll cope with that. thank u guys for the help. Best Regards..

                      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