Csharp/C#教程:C#中的数字文本框 – WPF分享


C#中的数字文本框 – WPF

我想在WPF中创建一个只接受数字的文本框…我已经重新申请并且人们说使用按键事件或屏蔽文本框,但它们是在Windows窗体中…

对于WPF:

private void textBox1_PreviewTextInput(object sender, TextCompositionEventArgs e) { if (!char.IsDigit(e.Text, e.Text.Length - 1)) e.Handled = true; } 

对于Windows窗体:

上述就是C#学习教程:C#中的数字文本框 – WPF分享的全部内容,如果对大家有所用处且需要了解更多关于C#学习教程,希望大家多多关注—计算机技术网(www.ctvol.com)!

 private void textBox1_KeyPress(object sender, KeyPressEventArgs e) { if (!char.IsDigit(e.KeyChar) ) e.Handled = true; } 

本文来自网络收集,不代表计算机技术网立场,如涉及侵权请联系管理员删除。

ctvol管理联系方式QQ:251552304

本文章地址:https://www.ctvol.com/cdevelopment/1018939.html

(0)
上一篇 2022年1月4日
下一篇 2022年1月4日

精彩推荐