An Easy Way to Set an Autonumber in a TextBox in C#
Submitted by janobe on Tuesday, March 26, 2019 - 11:39.
In this tutorial, I'll show you how to set autonumber in a textbox in c #. Autonumber is very useful in programming because it generates a unique id in every transaction made. In this way, you can easily identify what kind of data you have saved in the database if you are looking for it. Let’s begin.
The complete source code is included you can download it and run it on your computer.
For any questions about this article. You can contact me @
Email – [email protected]
Mobile No. – 09305235027 – TNT
Or feel free to comment below.
Creating Application
Step 1
Open Microsoft Visual Studio 2015 and create a new windows form application for c#.
Step 2
Do the form just like shown below.
Step 3
Double click the form and set a value in a textbox in the first load of the form.- private void Form1_Load(object sender, EventArgs e)
- {
- textBox1.Text = "0";
- }
Step 4
Double click the button and do the following codes to set an autonumber in a textbox. This codes will increment the number inside the textbox when the button is clicked.- private void button1_Click(object sender, EventArgs e)
- {
- int txt = 1;
- txt += int.Parse(textBox1.Text);
- textBox1.Text = txt.ToString();
- }
Add new comment
- 207 views