Page 1 of 1

ContextMenu: lock to one gridview (on tabcontrol page) + hide items

Posted: Thu Jan 23, 2020 12:57 pm
by stevens
Hi,

I have a Powershell Studio Form with tabcontrol in the main form.
In the tabcontrol there are several different gridviews (every tab -3 tabs- has one). On one of these gridviews there is a contextmenustrip active, which works fine.

No I needed another contextmenustrip for another gridview in another tab and saw that my contextmenustrip is active wherever I click in the form instead of locked to 1 gridview.

My question:
-how can I lock the contextmenu to 1 gridview in 1 tab (it should only appear there when rightclicking an item in that gridview)?
-how can I add another contextmenu that is 'locked' (appears only) on another gridview (other tab)
-can I hide specifc contexmenuitems for specific users if ($env:username) –eq .. then remove item or disable?
Note: I'm already hiding tabs using $Mytab = $tabcontrolMainForm.TabPages['Mytab']
if ... {$tabcontrolMainForm.TabPages.Remove($Mytab )} which works fine. Is there a similar approach to hide contextmenuitems?


Thanks!
J.

Re: ContextMenu: lock to one gridview (on tabcontrol page) + hide items

Posted: Thu Jan 23, 2020 1:16 pm
by jvierra
The context menustrip must be attached to the gridview and not the tab control or the tab page.

Re: ContextMenu: lock to one gridview (on tabcontrol page) + hide items

Posted: Thu Jan 23, 2020 1:22 pm
by stevens
Thanks for your quick reply!
Yes, exactly, but I can't find a way to change the way it is attached now to the gridview.
Also, any idea to hide a control in the context menu strip?

Re: ContextMenu: lock to one gridview (on tabcontrol page) + hide items

Posted: Thu Jan 23, 2020 1:25 pm
by jvierra
No idea what you mean. Just remove the contextmenu reference from the datagridview control in properties in the designer.

Re: ContextMenu: lock to one gridview (on tabcontrol page) + hide items

Posted: Mon Jan 27, 2020 6:10 am
by stevens
Thanks, didn't know there was a property contexmenustrip :-)