只允许使用十六进制数c#WP8.1

时间:2015-05-14 17:35:10

标签: c#

我尝试阻止任何不是十六进制数的数字,使用Virtualkey和你的代码

 private void TxthexSoma1_KeyDown(object sender, KeyRoutedEventArgs e)
    {

        if (e.Key == (VirtualKey)(65) ||
            e.Key == (VirtualKey)(66) ||
            e.Key == (VirtualKey)(67) ||
            e.Key == (VirtualKey)(68) ||
            e.Key == (VirtualKey)(69) ||
            e.Key == (VirtualKey)(70) ||
            e.Key == (VirtualKey)(48) ||
            e.Key == (VirtualKey)(49) ||
            e.Key == (VirtualKey)(50) ||
            e.Key == (VirtualKey)(51) ||
            e.Key == (VirtualKey)(52) ||
            e.Key == (VirtualKey)(53) ||
            e.Key == (VirtualKey)(54) ||
            e.Key == (VirtualKey)(55) ||
            e.Key == (VirtualKey)(56) ||
            e.Key == (VirtualKey)(57) ||
            e.Key == (VirtualKey)(20) ||
            e.Key == (VirtualKey)(8)  ||
            e.Key == (VirtualKey)(46))
        {
            e.Handled = false;
        }
        else
        {
            e.Handled = true;
        }

但是有一些问题,例如:如果第一个歌词是大写的则没有发生任何事情,而其他字符如:(,),#,!还有很多其他人都在接受

怎么修好了?

0 个答案:

没有答案