Percent Formatting
-
I love all the random formatting that is provided, but I'm having an issue with the default percent formatting. I databind a decimal value in a dataset to a textbox, and set the default formatting to "#,##0.##%" The problem is my end-user is slightly annoyed with the resulting format. If the end user inputs 2.34 (with their interpretation of 2.34%), it formats itself to "234%". If the end-user wants to end up with a display of "2.34%", he needs to entier either that, or .0234. My question is simply this, is there a way to override the percent formatting, or another custom string taht I can use that won't automatically do the "multiply by 100" in the format?
-
I love all the random formatting that is provided, but I'm having an issue with the default percent formatting. I databind a decimal value in a dataset to a textbox, and set the default formatting to "#,##0.##%" The problem is my end-user is slightly annoyed with the resulting format. If the end user inputs 2.34 (with their interpretation of 2.34%), it formats itself to "234%". If the end-user wants to end up with a display of "2.34%", he needs to entier either that, or .0234. My question is simply this, is there a way to override the percent formatting, or another custom string taht I can use that won't automatically do the "multiply by 100" in the format?
I can think of another way to do it, but it's a bit longer: 1- Create the text box. 2- Parse it into a float to validate the input 3- Format the float with your desired format into a string 4- Do whatever you want with that string The code I used is like this: float test = float.Parse(textBox1.Text); MessageBox.Show(test.ToString("#,###.##") + "%");
-
I love all the random formatting that is provided, but I'm having an issue with the default percent formatting. I databind a decimal value in a dataset to a textbox, and set the default formatting to "#,##0.##%" The problem is my end-user is slightly annoyed with the resulting format. If the end user inputs 2.34 (with their interpretation of 2.34%), it formats itself to "234%". If the end-user wants to end up with a display of "2.34%", he needs to entier either that, or .0234. My question is simply this, is there a way to override the percent formatting, or another custom string taht I can use that won't automatically do the "multiply by 100" in the format?
-
Use apostrophes in the format string to specify literal text: "#,##0.##'%'" --- b { font-weight: normal; }
That did it, thanks.