473,396 Members | 2,039 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,396 software developers and data experts.

C# winform masked textbox

newbie to .net
I have a masked textbox intended to display/input salary.
The mask is 999,999 or ###,###. When I place the info from the
database into the field it formats incorrectly.
The salary is 75000. In the textbox it displays 750,00
What am I doing wrong??
------------------------------------------------------------------------------------
Posted from WWWCoder.com (http://www.wwwcoder.com - The Web Developer's Resource site.
Get your free weblog, download free apps, read tutorials, and more.
Jul 24 '07 #1
2 11293

Try something like this:

string str = "75000";
System.Diagnostics.Debug.WriteLine(String.Format(" {0:#,#}",
System.Convert.ToUInt32(str)));

Adrian.
--
[Please mark my answer if it was helpful to you]


"ja*************@pearlcarroll.cm" wrote:
newbie to .net
I have a masked textbox intended to display/input salary.
The mask is 999,999 or ###,###. When I place the info from the
database into the field it formats incorrectly.
The salary is 75000. In the textbox it displays 750,00
What am I doing wrong??
------------------------------------------------------------------------------------
Posted from WWWCoder.com (http://www.wwwcoder.com - The Web Developer's Resource site.
Get your free weblog, download free apps, read tutorials, and more.
Jul 24 '07 #2
ja*************@pearlcarroll.cm wrote:
newbie to .net
I have a masked textbox intended to display/input salary.
The mask is 999,999 or ###,###. When I place the info from the
database into the field it formats incorrectly.
The salary is 75000. In the textbox it displays 750,00
What am I doing wrong??
That's because the control treats that as text, not a number. Since you
have specified 6 characters yet only provided 5, the control simply
fills in the text start at the left until it has placed all characters
in the field. You need to left pad your value with spaces so that
everything properly lines to the right.

salary = salary.PadLeft(6);
--
Tom Porterfield
Jul 24 '07 #3

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

Similar topics

7
by: |{evin | last post by:
I'm currently working on what has turned in to something much larger that I wanted it to be. The upside is that I'm getting $$ to do it... but anywho. I currently have textboxes set up to...
1
by: Kostis | last post by:
Hello there! I have created a windows application in VB.NET and I want to retrieve data from an access database. I create the OleDbConnection, an OleDbAdapter, a dataset and finally a Data Form...
7
by: DazedAndConfused | last post by:
Curently I manualy code keypress edits. i.e. allow only 3 digits before decimal and two digits after decimal in .NET. Is there an easy solution to mask text boxes? The MSMASK32.OCX from vb6...
0
by: Sharon | last post by:
hi all I have a small application assembled from C# winForm client side (few of them) C# webService at the server side
3
by: dmbuso | last post by:
I have a money field defined in a SQL Server 05 database with a value of 49.50. Also, it displays in SQL Server as 49.5000. I have a form in VB.NET 2005 and I'm using the new MaskedTextBox control...
0
by: james.czebiniak | last post by:
newbie to .net I have a masked textbox intended to display/input salary. The mask is 999,999 or ###,###. When I place the info from the database into the field it formats incorrectly. The salary...
2
by: gayano | last post by:
Hi, I'm using Visual studio 2005 pro Ver..]]] I have a Form named form1 textbox named txtName masked textbox (Date Masked) named txtMaskedDate and a button to add data named btnAdd dim...
3
by: gayano | last post by:
Hi, I'm using Visual studio 2005 pro Ver..]]] I have a Form named form1 textbox named txtName masked textbox (Date Masked) named txtMaskedDate and a button to add data named btnAdd dim...
0
by: michels287 | last post by:
I have a masked textbox on my form. I have an onscreen keyboard with numbers only. The masked format for the masked textbox is: (###) ### - #### I want to make sure they enter the phone...
3
by: buddyr | last post by:
Hello, I have a texbox with error provider control: if(textbox.text.length <=0) { errorprovider1.seterror(textbox,"enter part number"); } else { errorprovider1.seterror(textbox, "");
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: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.