c# - Why does my MenuStrip appear in the incorrect Location on first click? -


i'm working on vb winforms project (although i'm fine c# solution) , have following set up:

  • i have contextmenustrip on form, mscreatereports
  • i have menustrip @ top of form 1 menu item being create reports , dropdown set mscreatereports
  • i have command button on form cmdcreatereports

now, command button, have following code click event:

private sub cmdcreatereports_click(byval sender system.object, byval e system.eventargs) handles cmdcreatereports.click     mscreatereports.show(cursor.position.x, cursor.position.y) end sub 

edit (update / explanation):


basically, i'm looking functionality-wise have contextmenustrip able show in 1 of 2 different places, depending on user clicks... if click on menu option, context menu appears drop-down on create reports menu item or if user clicks command button, menu apeear context menu on side of mouse pointer. want same menu able appear on either 1 of these 2 locations depending on user clicks make menu appear.


now, problem only first time command button clicked, contextmenustrip appears top menu, rather on top of command button, to.

after first click, menu appears in correct location... did wrong / how can fix this??

thanks!!

i have same problem (i'm using visual studio 2010 sp1, , c#). don't think did wrong, looks winforms bug me.

i fixed this:

1) have unset (using visual designer) dropdown property of main strip item.

2) have defined opening event on contextmenustrip, , dropdownopening event on main strip item this:

private void toolstripmymenuitem_dropdownopening(object sender, eventargs e) {     toolstripmymenuitemmylists.dropdown = contextmenustrip; }  private void contextmenustrip_opening(object sender, canceleventargs e) {     toolstripmymenuitemmylists.dropdown = contextmenustrip; } 

and don't have problem anymore. hope :-)


Comments

Popular posts from this blog

monitor web browser programmatically in Android? -

Shrink a YouTube video to responsive width -

wpf - PdfWriter.GetInstance throws System.NullReferenceException -