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. Custom MenuItem

Custom MenuItem

Scheduled Pinned Locked Moved C#
helpquestion
5 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.
  • A Offline
    A Offline
    Anonymous
    wrote on last edited by
    #1

    I have been tasked with creating a custom MenuItem. I can easily derive a class from System.Windows.Forms.MenuItem and add some methods to it. However, where I am having a problem is adding drag/drop capability. I need to be able to drag a MenuItem onto a toolbar. MenuItems do not support the DoDragDrop method which is what I would normally use. Is it possible to add DragDropEffects to a MenuItem? Thanks, Bill

    I 1 Reply Last reply
    0
    • A Anonymous

      I have been tasked with creating a custom MenuItem. I can easily derive a class from System.Windows.Forms.MenuItem and add some methods to it. However, where I am having a problem is adding drag/drop capability. I need to be able to drag a MenuItem onto a toolbar. MenuItems do not support the DoDragDrop method which is what I would normally use. Is it possible to add DragDropEffects to a MenuItem? Thanks, Bill

      I Offline
      I Offline
      if_mel_yes_else_no
      wrote on last edited by
      #2

      You can fake it pretty easily. When the MenuItem catches a mouseDown, change the cursor of the MenuItem and the main application to something that looks like a cursor with a drag item. Then set your desired receiver's state to 'RECEIVING'. When the receiving control catches a mouseUp and it's in the 'RECEIVING' state, it will perform the operation just as if the MenuItem was really dragged. Now just set the cursor for the MenuItem and main application back to default.

      A 1 Reply Last reply
      0
      • I if_mel_yes_else_no

        You can fake it pretty easily. When the MenuItem catches a mouseDown, change the cursor of the MenuItem and the main application to something that looks like a cursor with a drag item. Then set your desired receiver's state to 'RECEIVING'. When the receiving control catches a mouseUp and it's in the 'RECEIVING' state, it will perform the operation just as if the MenuItem was really dragged. Now just set the cursor for the MenuItem and main application back to default.

        A Offline
        A Offline
        Anonymous
        wrote on last edited by
        #3

        if_mel_yes_else_no wrote: You can fake it pretty easily. When the MenuItem catches a mouseDown The problem is that a MenuItem doesn't have standard MouseDown/Up/Move events. It just has a Click event whose parameter is a plain System.EventArgs not MouseEventArgs so I don't have access to the information that would be in MouseEventArgs. Without being able to detect if I have a left or right-click or if the Ctrl key is pressed I don't see how to tell the difference between a normal click on a MenuItem and the click that is to start the drag operation. Thanks, Bill

        I 1 Reply Last reply
        0
        • A Anonymous

          if_mel_yes_else_no wrote: You can fake it pretty easily. When the MenuItem catches a mouseDown The problem is that a MenuItem doesn't have standard MouseDown/Up/Move events. It just has a Click event whose parameter is a plain System.EventArgs not MouseEventArgs so I don't have access to the information that would be in MouseEventArgs. Without being able to detect if I have a left or right-click or if the Ctrl key is pressed I don't see how to tell the difference between a normal click on a MenuItem and the click that is to start the drag operation. Thanks, Bill

          I Offline
          I Offline
          if_mel_yes_else_no
          wrote on last edited by
          #4

          You must be using studio 2003. In studio 2005 the MenuItems have all the mouse events. There's a chance that you could look into having the application catch any system mouseDowns, and using the mouseEventArgs's X and Y coordinates, try to figure out if it came from your menuItem... but that sounds like a lot of hassle. How about a seperate menu item called "Add Bla". After you click it the cursor changes as I said before, and you can click on the receiver. It's not exactly a drag so much as a 'click to place', but it's better than nothing.

          A 1 Reply Last reply
          0
          • I if_mel_yes_else_no

            You must be using studio 2003. In studio 2005 the MenuItems have all the mouse events. There's a chance that you could look into having the application catch any system mouseDowns, and using the mouseEventArgs's X and Y coordinates, try to figure out if it came from your menuItem... but that sounds like a lot of hassle. How about a seperate menu item called "Add Bla". After you click it the cursor changes as I said before, and you can click on the receiver. It's not exactly a drag so much as a 'click to place', but it's better than nothing.

            A Offline
            A Offline
            Anonymous
            wrote on last edited by
            #5

            Yes, I am using studio 2003. I think we will wait for the final release of studio 2005 before adding drag & drop to our menus. Thanks for your help, Bill

            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