Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9152891
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T12:09:56+00:00 2026-06-17T12:09:56+00:00

Im using Visual Studio 2010, windows form (c#). I need change decimals place of

  • 0

Im using Visual Studio 2010, windows form (c#).

I need change decimals place of value in textbox using numericUpDown1.

example:

enter image description here enter image description here

enter image description here enter image description here

enter image description here enter image description here

enter image description here enter image description here

enter image description here enter image description here

I tryed this code:

private void numericUpDown1_ValueChanged(object sender, EventArgs e)
    {

      //  tbxConvertito.Text = (decimal.Parse(tbxConvertito.Text) * 10m).ToString();

        if (numericUpDown1.Value == 0)
        {
            int decimalPlace = 0;
           // Decimal xDecimal = decimal.Parse(tbxConvertito.text);

            decimal xDecimal = decimal.Parse(tbxConvertito.Text);
            tbxConvertito.Text = (Math.Round(xDecimal, decimalPlace)).ToString();
        }

        if (numericUpDown1.Value == 1)
        {
            int decimalPlace = 1;
            // Decimal xDecimal = decimal.Parse(tbxConvertito.text);

            decimal xDecimal = decimal.Parse(tbxConvertito.Text);
            tbxConvertito.Text = (Math.Round(xDecimal, decimalPlace)).ToString();
        }

    }

but not work. How can I solve this, please?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T12:09:57+00:00Added an answer on June 17, 2026 at 12:09 pm

    You should create field with decimal value, to keep original value.

    If you do that:

    int decimalPlace = 1;
    decimal xDecimal = decimal.Parse(tbxConvertito.Text);
    tbxConvertito.Text = (Math.Round(xDecimal, decimalPlace)).ToString();
    

    You lose original value of your decimal variable.

    Try this:

    public partial class Form1 : Form
    {
            public decimal myDecimal = 3755.25012345M;
    
            public Form1()
            {
                InitializeComponent();
    
                tbxConvertito.Text = myDecimal.ToString();
    
                numericUpDown1_ValueChanged(this, EventArgs.Empty);
            }
    
            private void numericUpDown1_ValueChanged(object sender, EventArgs e)
            {          
                int decimalPlace = (int)numericUpDown1.Value;
                tbxConvertito.Text = Decimal.Round(myDecimal, decimalPlace).ToString();
            }
    }
    

    Solution without use Round method:

      public partial class Form1 : Form
        {
            public decimal myDecimal = 3755.25012345M;
    
            public Form1()
            {
                InitializeComponent();
    
                tbxConvertito.Text = myDecimal.ToString();
    
                numericUpDown1_ValueChanged(this, EventArgs.Empty);
            }
    
            private void numericUpDown1_ValueChanged(object sender, EventArgs e)
            {          
                int decimalPlace = (int)numericUpDown1.Value;
    
                string[] numbers = myDecimal.ToString().Split(new char[] { '.', ',' });
    
                string tmp = string.Empty;
    
                if (decimalPlace <= numbers[1].Length)
                {
                    tmp = "," + numbers[1].Substring(0, decimalPlace);
    
                    if (tmp.EndsWith(","))
                        tmp = string.Empty;
                }
                else
                    tmp = "," + numbers[1];
    
                tbxConvertito.Text = numbers[0] + tmp;
            }
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Using a chart control on a windows form in C#, with visual studio 2010
I have developed a Windows Form Application in Visual Studio 2010, i.e., using .Net
I'm using Visual Studio 2010 to create a C# Windows Form application. In the
Using C# and Visual Studio 2010 (Windows Form Project), InstaSharp and Newtonsoft.Json libraries. I
I am creating a C# windows form application using Visual Studio 2010. The end
I'm programming in C++ using Visual Studio 2010 using a Windows Form to create
I am creating Windows Application Form using Visual Studio 2010. For now, I am
I'm using Visual Studio 2010 and I'm working on a windows application form. I'm
I'm using visual studio 2010 do developt my Windows phone application! I'm newbie and
I'm running Windows 7 Ultimate (64 bit) using Visual Studio 2010 RC. I recently

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.