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 497131
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T05:45:08+00:00 2026-05-13T05:45:08+00:00

I need to validate a textbox as follows: When the user changes focus from

  • 0

I need to validate a textbox as follows:

When the user changes focus from that textbox, I want to show the properly formated currency value, but without lost the real user-entered value, Because i need it for later Calculations, and if is the case, for later editing from the user…

Can i do that? i don’t want to have another variable just for that, and i remmeber the “validating” (i think) event on datagrid view that lets you keep the value and format that value, so if you have to change or use for calculations, you just use the VALUE property, and for showing, it uses the FORMATEDVALUE property…
Can i do that?

Thanks!

  • 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-05-13T05:45:08+00:00Added an answer on May 13, 2026 at 5:45 am

    Define a function which formats the user entered value and returns the formatted value. On the LostFocus event of the text box you can accept the value entered by the user and store it into a variable. Then, pass the variable value as a parameter to the function. Format your value and return the value to the textbox.

        private void textBox1_Leave(object sender, EventArgs e)
        {
            Int32 original_value = Convert.ToInt32(textBox1.Text);
            textBox1.Text = Format(original_value).ToString();
            //original_value still holds the value that the user entered.
            //textbox holds the formated value.
    
        }
        public int Format(int a)
        {
            //code to format your input value
            return a;
        }
    

    This way your variable holds the acutal value entered by the user and the textbox will display the formatted value. Does this help.

    If you do not want to use another variable at all then you can perhaps make your own class control that inherits the textbox control, or just get the source, and use the Override attribute for the class.
    this might help.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 290k
  • Answers 290k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer You want the p4 fixes command: p4 fixes -j <job> May 13, 2026 at 5:50 pm
  • Editorial Team
    Editorial Team added an answer If you're using Rails >=2.2 and a standard HABTM association… May 13, 2026 at 5:50 pm
  • Editorial Team
    Editorial Team added an answer from the .designer-file of my .edmx-file, eg public partial class… May 13, 2026 at 5:50 pm

Related Questions

This seems like it should have a simple solution but I can't seem to
I have a page which has an Html.DropDownList which takes in a viewdata parameter.
one of the fields on my form is a textbox that the user types
I'm running into real difficulties validating XML with XSD . I should prefix all
I am trying to use Validation in WPF. I created a NotNullOrEmptyValidationRule as shown

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.