C# how to use e.suppresskeypress to restrict \ * ? " and other entries -
i can use e.suppresskeypress restrict key presses in textbox cannot figure out how use suppress entries \ * ? or ". can use suppress when e.keycode == key.something, there no key.(special characters). can suppress entries such letters or numbers not these special characters. can suppress these special characters?
interesting question, due fact performing double keypress (i assume press shift in order question mark have do).
i not entirely sure if answer you, try catch modifier key (which shift key instance) combined keyvalue (ie. ascii value of particular key want exclude).
just example, try within keydown eventhandler:
int questionmark = 191; //this might not correct key int star = 56; int quotekey = 222; if (e.modifiers.equals(keys.shift)) { if (e.keyvalue.equals(questionmark) || e.keyvalue.equals(star) || e.keyvalue.equals(quotekey)) { e.suppresskeypress = true; } }
i can imagine ascii values might differ, depending on keyboard layout use. worth try.
Comments
Post a Comment