hi everyone,
in a GUI i'm working on, i would like to use the same ContextMenuStrip that i would associate to a few datagridview to select an item. since it's the same function that is running, it's only logical to use the same strip.
I've created 2 datagridview, associated my strip to each, now i'm trying to understand how to get the calling control.
is there a way to identify the control who called the strip?
thank you!
ContextMenuStrip question
Forum rules
Do not post any licensing information in this forum.
Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
Do not post any licensing information in this forum.
Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
Re: ContextMenuStrip question
Use the same event for all controls that share the strip. The current control that the strip is associated with is the "$contextmenustrip1.SourceControl"
Example:
Example:
Code: Select all
$testToolStripMenuItem_Click={
Write-Host $contextmenustrip1.SourceControl.Name
}
Re: ContextMenuStrip question
Here is a better example:
Code: Select all
$testToolStripMenuItem_Click={
Write-Host $this.Name
Write-Host $contextmenustrip1.SourceControl.Name
}
$testerToolStripMenuItem_Click={
Write-Host $this.Name
Write-Host $contextmenustrip1.SourceControl.Name
}