Example #1
0
        //键盘事件ctrl+c和ctrl+v和ctrl+x和delete
        private void dataGridView1_KeyDown(object sender, KeyEventArgs e)
        {
            //ctrl+c
            if (Control.ModifierKeys == Keys.Control && e.KeyCode == Keys.C)
            {
                Clipboard.SetDataObject(dataGridView1.GetClipboardContent());
            }

            //ctrl+x
            if (Control.ModifierKeys == Keys.Control && e.KeyCode == Keys.X)
            {
                Clipboard.SetDataObject(dataGridView1.GetClipboardContent());
                //this.dataGridView1.CurrentCell = null;
                DgvCtrl.clearSelectCell(this.dataGridView1);
            }


            //ctrl+v
            if (Control.ModifierKeys == Keys.Control && e.KeyCode == Keys.V)
            {
                DgvCtrl.pasteToDataGridView(this.dataGridView1);
            }

            //delete
            if (e.KeyCode == Keys.Delete)
            {
                DgvCtrl.clearSelectCell(this.dataGridView1);
            }
        }
Example #2
0
 //右键菜单命令-粘贴
 private void 粘贴ToolStripMenuItem_Click(object sender, EventArgs e)
 {
     DgvCtrl.pasteToDataGridView(this.dataGridView1);
 }