How can I make ContextMenuStrip aware of which DataGridView I clicked right from?

DataGridView is dynamically generated, bind ContextMenuStrip to implement right-click menu, want to achieve the function of copying data on DataGridView. There is more than one DataGridView on the
interface. I want to use a menu handler to implement the function. The question is, how can I let ContextMenuStrip know which DataGridView pop-up menu I right-clicked?

the function of right-click menu is as follows:

 private void ToolStripMenuItem1_Click(object sender, EventArgs e)
{
        DataGridView dgv = ;
            if (dgv.SelectedCells.Count > 0)
            {
                Clipboard.SetDataObject(dgv.GetClipboardContent()); //
            }
            else
            {
                MessageBox.Show("");
            }
}
May.27,2022

  1. The ContextMenuStrip.SourceControl property identifies the control that triggered the menu.
  2. The first parameter of the
  3. event handling method object sender usually identifies the source control.

refer to
https://docs.microsoft.com/en...

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1bca3fb-30a04.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1bca3fb-30a04.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?