gpt4 book ai didi

c# - 如何防止在非零数字之前输入零?

转载 作者:太空宇宙 更新时间:2023-11-03 19:17:57 25 4
gpt4 key购买 nike

在 C# 中,WinForms 如何停止以下输入:

0000000000001234556

0000.123456

00000123456.123456

最佳答案

如果你想要 1234556 而不是 000000001234556
然后你可以把它转换成Int,Double或者你想要的任何其他数据类型

第二个选项是使用keypress 事件

private void textBox1_KeyPress(object sender, System.Windows.Forms.KeyPressEventArgs e)
{
if (e.KeyCode == ascii of 0)
{
e.Handled = false;
}
}

关于c# - 如何防止在非零数字之前输入零?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14801882/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com