c# - Right click menu and menu line -


goal:
right clicking in listview , choose different option.

problem:
there 2 problem:
*when i'm right clicking, left corner of menu not located in arrow's spot location.
*how create line in menu?

the main problem menu

the menu not located in right spot once right clicking

need support create these 2 redmark.

request fulfill these 2 red marked

private void lstv_stock_mouseup(object sender, mouseeventargs e) {     switch (e.button)     {          // right mouse click             case mousebuttons.right:                   contextmenu mycontextmenu = new contextmenu();                  menuitem menuitem1 = new menuitem("new product");                 menuitem menuitem2 = new menuitem("delete");                 menuitem menuitem3 = new menuitem("add quantity");                   // clear added menuitems.                 mycontextmenu.menuitems.clear();                  mycontextmenu.menuitems.add(menuitem1);                 mycontextmenu.menuitems.add(menuitem2);                 mycontextmenu.menuitems.add(menuitem3);                  if (lstv_stock.selecteditems.count > 0)                  {                      foreach (listviewitem item in lstv_stock.selecteditems)                     {                         mycontextmenu.menuitems[1].visible = true;                         mycontextmenu.menuitems[2].visible = true;                         mycontextmenu.menuitems[0].visible = false;                     }                  }                 else                 {                     mycontextmenu.menuitems[1].visible = false;                     mycontextmenu.menuitems[2].visible = false;                     mycontextmenu.menuitems[0].visible = true;                 }                  mycontextmenu.show(lstv_stock, this.pointtoclient(cursor.position), leftrightalignment.right);                    menuitem1.click += new system.eventhandler(this.menuitem1_click);                   break;          } 

for positioning, can replace your

mycontextmenu.show(lstv_stock, this.pointtoclient(cursor.position), leftrightalignment.right); 

to

mycontextmenu.show(lstv_stock, e.location(), leftrightalignment.right); 

or point e.x,e.y. not this.pointtoclient, mouseeventargs generating event. can check wahat mouseevent have here.


Comments

Popular posts from this blog

c# - Is it possible to remove an existing registration from Autofac container builder? -

c++ - Warning : overflow in implicit constant conversion -