Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
OnKeyPress and paste
Message
De
04/03/2005 10:55:25
Cetin Basoz
Engineerica Inc.
Izmir, Turquie
 
Information générale
Forum:
ASP.NET
Catégorie:
Formulaires
Divers
Thread ID:
00992739
Message ID:
00992748
Vues:
20
>Does Ctrl+V count as one keypress or two keypresses?
>Considder the following code that I have in my OnKeyPress
>
>protected override void OnKeyPress(System.Windows.Forms.KeyPressEventArgs e)
>{
>	switch(e.KeyChar)
>	{
>		case '\b':
>		case '0':
>		case '1':
>		case '2':
>		case '3':
>		case '4':
>		case '5':
>		case '6':
>		case '7':
>		case '8':
>		case '9':
>		{
>			e.Handled = false;
>		}break;
>//		case System.Windows.Forms.Keys.ControlKey + System.Windows.Forms.Keys.V:
>//		{
>//			System.Windows.Forms.MessageBox.Show("ctrl+v");
>//                         e.Handled = false;
>//		}break;
>		default:
>		{
>			e.Handled = true;
>		}break;
>	}
>}
>
>I have commented out some of the code above, because it doesn't compile. Any hints regarding how I can allow paste would be appreciated.
>
>Thanks,
>Einar

Einar,
If you're using KeyPressEventArgs then it's a single value of keycode (like asc() in VFP).
if (e.KeyChar == 'V') // Shift+v is upper V assuming caps is off
With KeyEventArgs you've both the KeyCode and modifiers. ie:

if (e.KeyCode == Keys.V && e.Shift)

Cetin
Çetin Basöz

The way to Go
Flutter - For mobile, web and desktop.
World's most advanced open source relational database.
.Net for foxheads - Blog (main)
FoxSharp - Blog (mirror)
Welcome to FoxyClasses

LinqPad - C#,VB,F#,SQL,eSQL ... scratchpad
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform