在C#中如何利用快捷键来调出对话框,比如我按键盘上面的Ctrl+A能够调出一个快捷键,这个要如何才能够实现呢?

解决方案 »

  1.   

    没有明白lz的意思,你是指自定义Ctrl+A就弹出一个对话框?
      

  2.   


       private void Form1_KeyDown(object sender, KeyEventArgs e)
            {            if (e.Control&&e.Shift && (e.KeyCode == Keys.V))
                {
                    MessageBox.Show("Ctrl+Shift+V");
                }        }
    要设置Form的KeyPreview=true
      

  3.   


    嗯,就是那个意思,就是在一个首先运行程序出现 一个界面,然后焦点在那个界面上面,然后再按Ctrl+A就再弹出一个对话框就行了,这个该如何实现呢?
      

  4.   

    那就是在响应一个keydown事件,然后在里面对key值进行判断,如果是组合键的话就响应,否则就释放。
      

  5.   

    这样private void Form1_KeyDown(object sender, KeyEventArgs e)
            {
                if (e.KeyCode == Keys.A && e.Modifiers = Keys.Control)
                {
                    Form2 fr= new Form2();
                    fr.Show();
                }
            }
      

  6.   

     if (e.Control&&e.Shift && (e.KeyCode == Keys.V))
                {
                    MessageBox.Show("Ctrl+Shift+V");
                }
      

  7.   

    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Text;
    using System.Windows.Forms;namespace WindowsApplication5
    {
        public partial class Form1 : Form
        {
            public Form1()
            {
                InitializeComponent();
            }        private void Form1_KeyDown(object sender, KeyEventArgs e)
            {
                if (e.KeyCode == Keys.A && e.Modifiers == Keys.Control)
                {
                    Form2 fr = new Form2();
                    fr.Show();
                }
            }
        }
    }按住Ctrl +A弹出Form2窗体