none
Format Decimal places button 1 - 9 RRS feed

  • Question

  • hey i am using c# windows form. i want to do this. The format button allows the display to be configured to show between 1-9 decimal places. Entering the value 0 when setting the format removes all formatting control. i got a format button and got buttons 0 - 9 to do the decimal places. hope someone can help :)
    Sunday, November 13, 2011 6:48 PM

Answers

All replies

  • Try this Code

     

                decimal dInput = 100;
                int iDec = 9;  //0-9  Text Box Value
                string StringFormat="0." + new string('0',iDec);
                String dOutput = dInput.ToString(StringFormat);
                txtOutput.Text = dOutput;
    
    



    Happy Coding, RDRaja
    Sunday, November 13, 2011 7:47 PM
  • I done this now :)
    • Marked as answer by Welshy10 Wednesday, November 16, 2011 12:03 PM
    • Edited by Welshy10 Wednesday, November 16, 2011 12:03 PM
    Tuesday, November 15, 2011 11:35 PM
  • Hi stefanere2k9,

    I glad to hear that you solved the issue. Could you please share the solution here? If you can, it would help other community members who have similar problems.

    In addition, if RDRaja’s suggestion helped, please mark it as answer. Thanks.

    Best Regards,


    Bob Wu [MSFT]
    MSDN Community Support | Feedback to us
    Thursday, November 17, 2011 2:19 AM
    Moderator