Beispiel #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);
            }
        }
Beispiel #2
0
 //右键菜单命令-删除
 private void  除ToolStripMenuItem_Click(object sender, EventArgs e)
 {
     DgvCtrl.clearSelectCell(this.dataGridView1);
 }
Beispiel #3
0
 //右键菜单命令-剪切
 private void 剪切ToolStripMenuItem_Click(object sender, EventArgs e)
 {
     Clipboard.SetDataObject(dataGridView1.GetClipboardContent());
     //this.dataGridView1.CurrentCell = null;
     DgvCtrl.clearSelectCell(this.dataGridView1);
 }