textbox control

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • kidzero

    textbox control

    Hello,

    i have text box control in from(windows form). Now i want that this textbox
    could accept only numeric values. In MFC editbox had special option (number)
    and everything was well, but in C# i can't find anything like that.

    Programming language C#

    Thank you.


  • Ignacio Machin

    #2
    Re: textbox control

    Hi,

    This issue has been discussed before in this NG, take a look at the history
    in google:


    This is a method that I have used:



    Hope this help,

    --
    Ignacio Machin,
    ignacio.machin AT dot.state.fl.us
    Florida Department Of Transportation

    "kidzero" <kidzero@takas. lt> wrote in message
    news:ONA$$rmhDH A.3764@tk2msftn gp13.phx.gbl...[color=blue]
    > Hello,
    >
    > i have text box control in from(windows form). Now i want that this[/color]
    textbox[color=blue]
    > could accept only numeric values. In MFC editbox had special option[/color]
    (number)[color=blue]
    > and everything was well, but in C# i can't find anything like that.
    >
    > Programming language C#
    >
    > Thank you.
    >
    >[/color]


    Comment

    • Jeff

      #3
      Re: textbox control

      If you're interested, check out the article at:


      This article includes the C# source code for 9 different text box controls
      including: Alphanumeric TextBox, Currency TextBox, Date TextBox, DateTime
      TextBox, Integer TextBox, Masked TextBox, Multi-Masked TextBox, Numeric
      TestBox, and Time TextBox.

      It's a well-written article and nice example of C# code.

      - FWIW, Jeff


      "kidzero" <kidzero@takas. lt> wrote in message
      news:ONA$$rmhDH A.3764@tk2msftn gp13.phx.gbl...[color=blue]
      > Hello,
      >
      > i have text box control in from(windows form). Now i want that this[/color]
      textbox[color=blue]
      > could accept only numeric values. In MFC editbox had special option[/color]
      (number)[color=blue]
      > and everything was well, but in C# i can't find anything like that.
      >
      > Programming language C#
      >
      > Thank you.
      >
      >[/color]


      Comment

      • Ayca Aksu

        #4
        Re: textbox control

        take a look at the following article. basically you have two choices:

        1. let the user write whatever he/she wants, then show an error message and
        focus the textbox using validating and validated events

        2. you can detect the characters entered into the textbox using the keydown
        or some other event and simply ignore that character (in your case which are
        not numeric)



        "kidzero" <kidzero@takas. lt> wrote in message
        news:ONA$$rmhDH A.3764@tk2msftn gp13.phx.gbl...[color=blue]
        > Hello,
        >
        > i have text box control in from(windows form). Now i want that this[/color]
        textbox[color=blue]
        > could accept only numeric values. In MFC editbox had special option[/color]
        (number)[color=blue]
        > and everything was well, but in C# i can't find anything like that.
        >
        > Programming language C#
        >
        > Thank you.
        >
        >[/color]


        Comment

        • kidzero

          #5
          Re: textbox control

          Thank you for the answers ! :)


          "kidzero" <kidzero@takas. lt> wrote in message
          news:ONA$$rmhDH A.3764@tk2msftn gp13.phx.gbl...[color=blue]
          > Hello,
          >
          > i have text box control in from(windows form). Now i want that this[/color]
          textbox[color=blue]
          > could accept only numeric values. In MFC editbox had special option[/color]
          (number)[color=blue]
          > and everything was well, but in C# i can't find anything like that.
          >
          > Programming language C#
          >
          > Thank you.
          >
          >[/color]


          Comment

          Working...