473,385 Members | 1,569 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Format a textbox to display as a percentage

Arrggg…Format String Hell…Hello there,

I am attempting to format a decimal value as a % (percentage).
That is; I want .12 to be displayed and edited as 12%
No matter what I try I cant get it to work :(
I can get it working for display format, but not for the editformat :(

Below is my code

Me.txtDefaultAdminFeePercentage.Properties.Display Format.FormatType =
FormatType.Numeric
Me.txtDefaultAdminFeePercentage.Properties.Display Format.FormatString =
"{0:0%}"
Me.txtDefaultAdminFeePercentage.Properties.EditFor mat.FormatType =
FormatType.Numeric
Me.txtDefaultAdminFeePercentage.Properties.EditFor mat.FormatString =
"{0:0%}"

Any ideas would be greatly appreciated

Thank you for taking the time to read my post
John


Oct 15 '07 #1
2 15366
On Oct 15, 10:52 am, "John" <nos...@nospam.comwrote:
Arrggg...Format String Hell...Hello there,

I am attempting to format a decimal value as a % (percentage).
That is; I want .12 to be displayed and edited as 12%
No matter what I try I cant get it to work :(
I can get it working for display format, but not for the editformat :(

Below is my code

Me.txtDefaultAdminFeePercentage.Properties.Display Format.FormatType =
FormatType.Numeric
Me.txtDefaultAdminFeePercentage.Properties.Display Format.FormatString =
"{0:0%}"
Me.txtDefaultAdminFeePercentage.Properties.EditFor mat.FormatType =
FormatType.Numeric
Me.txtDefaultAdminFeePercentage.Properties.EditFor mat.FormatString =
"{0:0%}"

Any ideas would be greatly appreciated

Thank you for taking the time to read my post
John
Instead of using a textbox you might try using the masked text box
control instead (it should be listed in the components somewhere).
Then set the mask property. I'm sure this kind of thing is ideal for
it's use.

Phill

Oct 15 '07 #2
On Mon, 15 Oct 2007 19:52:02 +1000, "John" <no****@nospam.comwrote:
>Arrggg…Format String Hell…Hello there,

I am attempting to format a decimal value as a % (percentage).
That is; I want .12 to be displayed and edited as 12%
No matter what I try I cant get it to work :(
I can get it working for display format, but not for the editformat :(

Below is my code

Me.txtDefaultAdminFeePercentage.Properties.Displa yFormat.FormatType =
FormatType.Numeric
Me.txtDefaultAdminFeePercentage.Properties.Displa yFormat.FormatString =
"{0:0%}"
Me.txtDefaultAdminFeePercentage.Properties.EditFo rmat.FormatType =
FormatType.Numeric
Me.txtDefaultAdminFeePercentage.Properties.EditFo rmat.FormatString =
"{0:0%}"

Any ideas would be greatly appreciated

Thank you for taking the time to read my post
John
The format string you want is {0:p}

That will give you 12.00%

--
http://bytes.thinkersroom.com
Oct 15 '07 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Ryan Joseph So | last post by:
Hi, I made a custom textbox control inheriting from native windows textbox. The i made another form where i used the custom control, what i want to do is to bind the data from my datatable to...
1
by: nic | last post by:
Hi, I have a textbox value that I need to force (and format) to be a numeric value. For example, I want to allow a user to type 1000 or 1,000 or 1,000,000 but not something that is not numberic....
4
by: Art | last post by:
Hi, I have a MyTextBox class that inherits from TextBox. How do I make it display the information as, say 0.00. Sometimes the value will be typed by the user. Other times the value will be...
2
by: AMDRIT | last post by:
Hello Everyone, I would like to format the Display Members of a combobox's datasource. Is there a way to apply a format without subclassing the original datasource? For example, given a list of...
2
by: Randy | last post by:
I'm sure that this has been posted before, but I can't find it. Please accept my apologies for any redundancy. I have a textbox that contains numbers pulled from a SQL database column. These...
3
by: Ronald S. Cook | last post by:
Stupid q for the day, but if the user enters 2 in a textbox, I want to display as 2.00. If they enter 2.129 I want it as 2.13. I'm guessing will code in the validated method of the textbox,...
3
progdoctor
by: progdoctor | last post by:
Friends.. i have a problem.. How to make an input textbox work as desktop application textbox (money format case)? For example: when i entry 99200 in the inputbox and then press enter/tab key,...
3
by: engteng | last post by:
How do I format the textbox to 3 decimal point all the time? Regards, Tee
12
by: =?Utf-8?B?anAybXNmdA==?= | last post by:
I want to plant an Easter Egg in our software. We have a TextBox that is multiline and used to display all sorts of messages on the screen for our operators based on database queries and such. ...
2
by: =?Utf-8?B?R3JlZw==?= | last post by:
I come from an Access background. In Access I was able to format certain types of data such as SSN, Date, Phone Number, etc. with the special characters during data-entry and display, but the...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.