473,326 Members | 2,126 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,326 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 11279

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: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
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...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
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...

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.