CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 7 of 7

Thread: Context Menu

  1. #1
    Join Date
    Sep 2009
    Posts
    15

    Post Context Menu

    I have just added contextmenu from the toolbar added its sub item. I build the solution and run it.Nut on right click it is not showing the context menu. Anything else i need to do to show the context menu on right click in the editor. I am a very beginner to C Sharp.please help me.

  2. #2
    Join Date
    Oct 2009
    Posts
    26

    Re: Context Menu

    did u added menu items to that context menu. other wise u wont see anything after right click .

  3. #3
    Join Date
    Sep 2009
    Posts
    15

    Re: Context Menu

    Quote Originally Posted by lion.king View Post
    did u added menu items to that context menu. other wise u wont see anything after right click .
    i have already added menu item,but i am unable to see.

  4. #4
    Join Date
    Sep 2008
    Location
    Netherlands
    Posts
    865

    Re: Context Menu

    You need to show the contextmenu yourself

    Code example of showing a contextmenu when the mouse is clicked on a listview
    Code:
          private void listview1_MouseClick(object sender, MouseEventArgs e) {
             if (e.Button == MouseButtons.Right) {
                contextMenu1.Show(listview1, new Point(e.X, e.Y));
             }
          }

  5. #5
    Join Date
    Oct 2009
    Posts
    26

    Re: Context Menu

    Quote Originally Posted by dannystommen View Post
    You need to show the contextmenu yourself

    Code example of showing a contextmenu when the mouse is clicked on a listview
    Code:
          private void listview1_MouseClick(object sender, MouseEventArgs e) {
             if (e.Button == MouseButtons.Right) {
                contextMenu1.Show(listview1, new Point(e.X, e.Y));
             }
          }
    i am sure in c# or any .net no need of this code. if u added contextmenu to any item, it will be shown on right click.it wont show even when u add it is when u did not add any menu item to that context menu.

  6. #6
    Join Date
    Sep 2008
    Location
    Netherlands
    Posts
    865

    Re: Context Menu

    Quote Originally Posted by lion.king View Post
    i am sure in c# or any .net no need of this code. if u added contextmenu to any item, it will be shown on right click.it wont show even when u add it is when u did not add any menu item to that context menu.
    You are absolutely right! Missed that property till now..

    Any way, to test it, I created a ContextMenuStrip, and set a buttons ContextMenuStrip property to this menustrip. It worked fine.

    @bismitapadhi: Did you set this ContextMenuStrip property of the control where you want to show the context menu?

  7. #7
    Join Date
    Sep 2009
    Posts
    15

    Re: Context Menu

    Quote Originally Posted by dannystommen View Post
    You are absolutely right! Missed that property till now..

    Any way, to test it, I created a ContextMenuStrip, and set a buttons ContextMenuStrip property to this menustrip. It worked fine.

    @bismitapadhi: Did you set this ContextMenuStrip property of the control where you want to show the context menu?
    i haven't seted any control,in properties where i need to set the control.

Posting Permissions

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





Click Here to Expand Forum to Full Width

Featured