如何通过按空格键来增加文本框值 [英] How to increase textbox value by pressing space bar

查看:85
本文介绍了如何通过按空格键来增加文本框值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Windows窗体中有一个名为tblAmount的文本框。默认显示1.我需要按空格键然后特定文本框(名为tblAmount)将显示值2.如果我再次按空格键则显示3.请帮助我。

我写了以下代码:

I have a textbox in windows form named "tblAmount".By default it shows 1.I need when I press the space bar then a specific textbox's (named tblAmount) will show the value 2. If I press spacebar again it shows 3. Please help me.
I have written the following code :

private void Incrementbutton_KeyDown(object sender, KeyEventArgs e)
        {
if (e.KeyCode == Keys.Space)
            {
                
            }
}

推荐答案





设置textbox3.text默认值为任意整数值



on textbox3 keydown event

set textbox3.text default value to any integer value

if (e.KeyCode == 32) {
    if (string.IsNullOrEmpty(this.TextBox3.Text)) {
        this.TextBox3.Text = 0;
    }
    this.TextBox3.Text = Convert.ToInt32(this.TextBox3.Text) + 1;
}


按照先生的建议在支架内试试。 Prasad Avunoori

try this within the bracket as suggested by Mr. Prasad Avunoori
tblAmount.Text = Convert.ToInt(tblAmount.Text)+1;


这篇关于如何通过按空格键来增加文本框值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆