文本框中的自动递增编号 [英] auto increment number in text box

查看:116
本文介绍了文本框中的自动递增编号的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有两个两个文本框t1和t2

t1具有唯一的ID
t2是一个名字

当我单击添加按钮时,新的用户ID显示在t1上
然后输入名称,然后按保存按钮

等等,当我单击添加按钮t1时,它会自动增加

io请尝试很多但不清楚的方法

i have two two text boxes t1 and t2

t1 has unique id
t2 is a name

when i click on a add button new user id is shown on t1
and enter name and press save button

and so on when ever i click on add button t1 is automatically incremented

io try alot but not clear

推荐答案

可能会有所帮助,

It might be helpful,

namespace UITest
{
    using System;
    using System.Windows.Forms;
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void btnIncrement_Click(object sender, EventArgs e)
        {
            textBox1.Text = IncrementedResult(textBox2.Text).ToString();
        }

        private Int32 IncrementedResult(string dataToParse)
        {
            int result;
            return Int32.TryParse(dataToParse, out result) ? ++result : result;
        }
    }
}



:)



:)


在保存位置t1 = Convert.ToInt(t1.text)++;.


这篇关于文本框中的自动递增编号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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