Saturday 10 September 2011

Disable a particular key




First get a event of your text feild (like text box) in your project


double click on this event of your textbox or richtextbox
this event occurs when ever a key is pressed

now the code,
 private void richTextBox1_KeyDown(object sender, KeyEventArgs e)
        {
 


            /////////// do your work here
            if ( e.KeyCode == Keys.A)
            {
                e.Handled = true;
            }

       
        }





Enjoy the joy of Coding
God Bless You
Jai SiyaRam

Friday 9 September 2011

Alert on when a combination of keys is pressed




First get a event of your text feild (like text box) in your project


double click on this event of your textbox or richtextbox
this event occurs when ever a key is pressed

now the code,
 private void richTextBox1_KeyDown(object sender, KeyEventArgs e)
        {
   


            /////////// do your work here
            if (Control.ModifierKeys == Keys.Control && e.KeyCode == Keys.E)
            {
                MessageBox.Show("ctrl + e");
            }

         
        }





Enjoy the joy of Coding
God Bless You
Jai SiyaRam


Key Event

,If, you want to know that any key is pressed
then follow the following code:


First, get a key down event of your richtextbox or textbox
as it is given in this pic.



                        double click on this event of your textbox or rich text box
this event occurs when ever a key is pressed

...


now,
    private void richTextBox1_KeyDown(object sender, KeyEventArgs e)
        {
      

            if (e.KeyCode == Keys.Space)
            {
               /// do your work here
               MessageBox.Show("space");
            }
           

            if (e.KeyCode == Keys.F2)
            {
                MessageBox.Show("f2");
            }

        }




Enjoy the joy of Coding
God Bless You
Jai SiyaRam