当用户从特定单元格的上下文菜单中选择复制时,如何将数据网格单元格的内容复制到剪贴板?
public Form1()
{
InitializeComponent();
dataGridView1.MouseClick += dataGridView1_MouseClick;
}
void dataGridView1_MouseClick(object sender, MouseEventArgs e)
{
if (e.Button == MouseButtons.Right)
{
ContextMenu m = new ContextMenu();
m.MenuItems.Add(new MenuItem("Copy"));
int currentMouseOuverRow = dataGridView1.HitTest(e.X, e.Y).RowIndex;
m.Show(dataGridView1, new Point(e.X, e.Y));
}
}