c# - how to make a multiline textbox not accept Enter and Backspace -


i have multiline textbox shouldn't accept alphabets, numbers, newline(enter key) , backspace. in short, textbox.text shouldn't editable. want textbox accept 2 shortcut keys - control , control+r. 1 way can make textbox un-editable making read-only. textbox wont accept keystroke @ all. in short, shortcuts ( control , control+r) wont work( control + r) read-only method.

can in regard. that's have do.

one thing here not make textbox read-only , restrict characters(alphabets , digits) inputted in textbox. code:

    private void txtresult_keypress(object sender, keypresseventargs e)     {         // modifier keys, escape, enter, backspace etc accepted         e.handled = !char.iscontrol(e.keychar);     }      private void txtresult_keydown(object sender, keyeventargs e)     {         if (e.control == true)         {             if (e.keycode == keys.r)             {                 //             }             else             {                 //do             }         }          if (e.keycode == keys.escape)         {             //do         }     } 

with technique can shortcuts(control , control+r) working. trouble method enter , backspace keys work making possible edit text of textbox. how can restrict enter , backspace key being registered textbox, let control , escape??

did try suppresskeypress = true ?

private void textbox2_keydown(object sender, keyeventargs e)         {             if (e.control == true)             {                 if (e.keycode == keys.r)                 {                     //                 }                 else                 {                     //do                 }             }             else                 e.suppresskeypress = true;           } 

Comments

Popular posts from this blog

php - What is the difference between $_SERVER['PATH_INFO'] and $_SERVER['ORIG_PATH_INFO']? -

fortran - Function return type mismatch -

queue - mq_receive: message too long -