Results 1 to 7 of 7

Thread: [resolved] context Menu Position in Listview

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Mar 2006
    Posts
    24

    [resolved] context Menu Position in Listview

    HI
    I want to display the contextMenu once the user right-click in listview,
    but I can't make it to the click position.

    any idea ?


    cms_lvw_product.Show(listView1, new Point(Control.MousePosition.X, Control.MousePosition.Y));

    the position is not exactly on the click position.

  2. #2
    Fanatic Member Bombdrop's Avatar
    Join Date
    Apr 2001
    Location
    St Helens, England, UK
    Posts
    667

    Re: context Menu Position in Listview

    This can be archived by assigning the 'ContextMenuStrip ' property of the control to the ' contextMenuStrip' control this can be done at design or runtime.

    Code:
    this.TabPage1.ContextMenuStrip = contextMenuStrip1;

    Hope This Helps!!!

  3. #3

    Thread Starter
    Junior Member
    Join Date
    Mar 2006
    Posts
    24

    Re: context Menu Position in Listview

    listView1 is the ListView component;
    cms_lvw_product is the Context Menu.

    listView1.ContextMenuStrip = cms_lvw_product;
    listView1.ContextMenuStrip.Visible = true;

    however the context menu is still showing up in Right Top corner
    appreciate any help.

  4. #4
    Fanatic Member Bombdrop's Avatar
    Join Date
    Apr 2001
    Location
    St Helens, England, UK
    Posts
    667

    Re: context Menu Position in Listview

    where are you assigning the menu better to do it a desgin time or in the constructor of the form, this works for me.



    Code:
    		public MainForm()
    		{
    			//
    			// The InitializeComponent() call is required for Windows Forms designer support.
    			//
    			InitializeComponent();
    			this.listView1.ContextMenuStrip = this.contextMenuStrip1;
    			//
    			// TODO: Add constructor code after the InitializeComponent() call.
    			//
    		}

  5. #5

    Thread Starter
    Junior Member
    Join Date
    Mar 2006
    Posts
    24

    Re: context Menu Position in Listview

    once you did Right-Click first, it works fine on left/right mouse click
    but
    If you did Left Click first, then the menu will display in Top/Right corner,
    until you click the Right Click, then it become to the correct position.

    is a bug there or I should set something up?
    otherwise How could I disable LEFT mouse click ?

  6. #6

    Thread Starter
    Junior Member
    Join Date
    Mar 2006
    Posts
    24

    Re: context Menu Position in Listview

    More info:
    the problem maybe come with click event ??
    private void listView1_Click(object sender, EventArgs e)
    {
    listView1.ContextMenuStrip = cms_lvw_product;
    listView1.ContextMenuStrip.Visible = true;
    }

  7. #7

    Thread Starter
    Junior Member
    Join Date
    Mar 2006
    Posts
    24

    Re: context Menu Position in Listview

    resolved

    remove listView1.ContextMenuStrip.Visible = true;
    it works fine now
    Thx again

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