contextmenustrip opening event question
Posted: Wed Feb 10, 2016 12:12 am
I added a contextmenustrip control zu a form created with PowerShell Studio 2015. This form has TabControls and within the tabs many other controls. The context menu appears everywhere when I right-click with the mouse!
So I implemented the event contextmenustrip_Opening and set $_.Cancel = $true. The result is that it does not appear anywhere. I try to figure out, where the user clicked but that seems to be hard.... I did:
$control = $contextmenustrip1.SourceControl
$control contains always System.Windows.Forms.TabControl, TabPages.Count: 3, ..... etc, whatever the toString method returns. I rather would expect something like treecontrol1 or GridListView1 etc. How do I get this information? In the Opening Event I like to build a context menu depending on the control where the user clicked.
So I implemented the event contextmenustrip_Opening and set $_.Cancel = $true. The result is that it does not appear anywhere. I try to figure out, where the user clicked but that seems to be hard.... I did:
$control = $contextmenustrip1.SourceControl
$control contains always System.Windows.Forms.TabControl, TabPages.Count: 3, ..... etc, whatever the toString method returns. I rather would expect something like treecontrol1 or GridListView1 etc. How do I get this information? In the Opening Event I like to build a context menu depending on the control where the user clicked.