如何使用c#在文本框中自动生成数字值,该数字从文本框中的2001开始?

时间:2012-10-13 10:36:54

标签: c#-4.0

public partial class Form1 : Form
{
    int billno=2000;
    string code;
    public Form1()
    {
        InitializeComponent();
    }

    private void Form1_Load(object sender, EventArgs e)
    {
        billno = Convert.ToInt32(code);
        billno = billno + 1;
        textBox1.Text = " "+ billno;

    }

1 个答案:

答案 0 :(得分:1)

试试这个

public partial class Form1 : Form
{
    static int billno=2000;
    string code;
    public Form1()
    {
        InitializeComponent();
    }

    private void Form1_Load(object sender, EventArgs e)
    {
        billno = billno + 1;
        textBox1.Text = billno.ToString();

    }

此处billno会在每个Form加载事件中递增1。