Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
OnKeyPress and paste
Message
 
À
05/03/2005 05:32:07
Cetin Basoz
Engineerica Inc.
Izmir, Turquie
Information générale
Forum:
ASP.NET
Catégorie:
Formulaires
Divers
Thread ID:
00992739
Message ID:
00993057
Vues:
31
Cetin,
I originaly tried the code you proposed ((Keys.ControlKey & Keys.V)) and that was more or less the question I had in my original post. It would be nice if I could do it that way but I guess I kinda understand the reasons why it is not a good idea.
I ended up converting e.KeyChar to an Int32 and then doing a switch on the integer value, the only bad thing about that approach is that I have to comment each case just so I can easily see which character the ascii value is representing.
I must say that when I first started using .NET I found the switch statement very limiting, but I have gotten more and more used to it and I guess making the rules a little more strict will prevent me from shooting myself in the foot. I acctually don't mind getting compile time errors because I know that is one less potiential error that could be in the live application and debugging a compile time error is usually very very easy.

Einar

>Einar,
>You don't need the conversion:
>
>switch(e.KeyChar)
>case (char)(Keys.ControlKey & Keys.V):
>
>Should do.
>Update: It doesn't.
>I'm afraid you should know the code it produces (22):
>
>switch(e.KeyChar)
>case (char)22:
>
>However case in .Net is not as flexible as the one in VFP. Probably a series of if() would do better. ie:
>
>if (Control.ModifierKeys == Keys.Control && e.KeyChar == 22)
>{
>  e.Handled = true;
>  ((Control)sender).Text = "Ctrl+V pressed";
>}
>
>Cetin
Semper ubi sub ubi.
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform