Show Currency

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • thesti
    New Member
    • Nov 2007
    • 144

    Show Currency

    hello,

    i have a textbox for product price that the user will be able to enter some number and also a column in a datagridview to show the same price too,

    is it possible to show the thousands separator as a user types in. like when a user types 1000, it will be shown as 1,000. and if it possible, when i get the value in the textbox, can i convert it to an integer?

    thank you
  • kspiros
    New Member
    • Oct 2008
    • 16

    #2
    In order to convert a value to an integer you can do two things
    you can use this
    Code:
    X=Convert.ToInt32(textBox.Text);
    or this
    Code:
    X=Int32.Parse(textBox.Text) ;

    Comment

    • joedeene
      Contributor
      • Jul 2008
      • 579

      #3
      You can do something like this for the thousandths place...

      Code:
      private void textBox1_TextChanged(object sender, EventArgs e)
              {
                  if (textBox1.TextLength == 4)
                  {
                      textBox1.Text = textBox1.Text.Insert(1, ",");
      
                  }
                 
              }
      But after it inserts the text it brings the cursor to the beginning of the textbox. :( Why not have a button and parse the text and then you can convert it to an integer within that function too.

      joedeene

      Comment

      Working...