gpt4 book ai didi

c# - 在文本框中按键时禁用空格

转载 作者:行者123 更新时间:2023-11-30 14:31:30 25 4
gpt4 key购买 nike

我是 WinForms 的初学者,所以我想学习它,

如何禁用文本框中的空白按键?

private void TextBox1_KeyPress(object sender, KeyPressEventArgs e)
{
// MyTextBox.Text ...?
}

我们将不胜感激。

最佳答案

这就是你想要的,不允许所有空格

    private void TextBox_KeyPress(object sender, KeyPressEventArgs e)
{
e.Handled = (e.KeyChar == (char)Keys.Space);
}

关于c# - 在文本框中按键时禁用空格,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20115543/

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