Quantcast
Channel: Windows Forms Data Controls and Databinding forum
Viewing all articles
Browse latest Browse all 2535

How to get auto generate ID in Textbox on button click?

$
0
0

hello,

I need to Generate ID number Increment Auto or  any autogenerate number on button clcik , but how ? I tried the below code but everytime am getting the same id.

static string IncrementID(string startValue)
   {
     char letter = startValue[0];
     int len = startValue.Length - 1;
     int number = int.Parse(startValue.Substring(1));
     number++;
     if (number >= Math.Pow(10, len)) number = 1; // start again at 1
     return String.Format("{0}{1:D" + len.ToString() + "}", letter, number);
   }

private void btn_NewId(object sender, EventArgs e)
        {

   txt_ID.Text  = IncrementID("C00010"); // C00011
}
Thanks,


Viewing all articles
Browse latest Browse all 2535

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>