C# winform masked textbox

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • james.czebiniak@pearlcarroll.cm

    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.
  • =?Utf-8?B?QWRyaWFuIFZvaWN1?=

    #2
    RE: C# winform masked textbox


    Try something like this:

    string str = "75000";
    System.Diagnost ics.Debug.Write Line(String.For mat("{0:#,#}",
    System.Convert. ToUInt32(str))) ;

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




    "james.czebinia k@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.
    >

    Comment

    • Tom Porterfield

      #3
      Re: C# winform masked textbox

      james.czebiniak @pearlcarroll.c m 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

      Comment

      Working...