Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
OnKeyPress and paste
Message
 
À
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:
00992767
Vues:
19
I found that I can use Convert.ToInt32() on e.KeyChar and that returns 22 (like Eric said) for ctrl+v. The only problem is that I can check for that in the switch statement because you can only switch on one variable type at a time , and I am switching on a char type. I can either change my switch to switch on an int or add an additional if to check if Convert.ToInt32(e.KeyChar) is equal to 22. I think the rest of tis will be easy.

Thank you both for taking the tie to help me.

Einar

>>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
Semper ubi sub ubi.
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform