Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. WPF
  4. Generate decimal point automatically while entering in textbox in wpf

Generate decimal point automatically while entering in textbox in wpf

Scheduled Pinned Locked Moved WPF
csharpwpfhelp
8 Posts 5 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    sumit7034
    wrote on last edited by
    #1

    Hi I want to generate decimal point automatically while entering in textbox of wpf. Like the decimal point automatically generated while entering amount in ATM machine. Please help thanks in advance.

    C A P V 4 Replies Last reply
    0
    • S sumit7034

      Hi I want to generate decimal point automatically while entering in textbox of wpf. Like the decimal point automatically generated while entering amount in ATM machine. Please help thanks in advance.

      C Offline
      C Offline
      Christian Graus
      wrote on last edited by
      #2

      Handle the focus lost event, then take the text of the textbox, and make sure it's a number, then use the Substring function to split it and insert your decimal.

      Christian Graus Driven to the arms of OSX by Vista. Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.

      1 Reply Last reply
      0
      • S sumit7034

        Hi I want to generate decimal point automatically while entering in textbox of wpf. Like the decimal point automatically generated while entering amount in ATM machine. Please help thanks in advance.

        A Offline
        A Offline
        Abhinav S
        wrote on last edited by
        #3

        You could use a masked edit box. See here[^].

        The funniest thing about this particular signature is that by the time you realise it doesn't say anything it's too late to stop reading it. My latest tip/trick Visit the Hindi forum here.

        S 1 Reply Last reply
        0
        • A Abhinav S

          You could use a masked edit box. See here[^].

          The funniest thing about this particular signature is that by the time you realise it doesn't say anything it's too late to stop reading it. My latest tip/trick Visit the Hindi forum here.

          S Offline
          S Offline
          sumit7034
          wrote on last edited by
          #4

          But these are paid ones how can I implement these in my wpf window application

          1 Reply Last reply
          0
          • S sumit7034

            Hi I want to generate decimal point automatically while entering in textbox of wpf. Like the decimal point automatically generated while entering amount in ATM machine. Please help thanks in advance.

            P Offline
            P Offline
            Pete OHanlon
            wrote on last edited by
            #5

            You can use a MaskedTextBox[^] or FilteredTextBox[^].

            I have CDO, it's OCD with the letters in the right order; just as they ruddy well should be

            Forgive your enemies - it messes with their heads

            My blog | My articles | MoXAML PowerToys | Onyx

            1 Reply Last reply
            0
            • S sumit7034

              Hi I want to generate decimal point automatically while entering in textbox of wpf. Like the decimal point automatically generated while entering amount in ATM machine. Please help thanks in advance.

              V Offline
              V Offline
              V 0
              wrote on last edited by
              #6

              You can add normal winforms controls (like maskedtextbox) to WPF. From: Wrox, WPF Programmer’s Reference. Before you can use a WindowsFormsHost, you must perform three steps: 1. Add a reference to the WindowsFormsIntegration library. In Visual Studio, you can open the Project menu, select “Add Reference,” and select the library from the .NET tab on the Add Reference dialog. In Expression Blend, you can open the Project menu, select Add Reference, and then browse to the library file. On my system, it’s installed at C:\Program Files\ Reference Assemblies\Microsoft\Framework\v3.0\WindowsFormsIntegration.dll. 2. Add a reference to the System.Windows.Forms.dll library. Again, in Visual Studio, you can use the Project menu’s Add Reference command and select the library from the resulting dialog. In Expression Blend, you can again use the Project menu’s Add Reference command and then browse to the library file. On my system, it’s installed at C:\Windows\Microsoft.NET\ Framework\v2.0.50727\System.Windows.Forms.dll. 3. Add a namespace declaration for the Windows Forms namespace to the top of the XAML file. The declaration should look something like this: xmlns:wf=”clr-namespace:System.Windows.Forms;assembly=System.Windows.Forms” Hope this helps.

              V.

              P 1 Reply Last reply
              0
              • V V 0

                You can add normal winforms controls (like maskedtextbox) to WPF. From: Wrox, WPF Programmer’s Reference. Before you can use a WindowsFormsHost, you must perform three steps: 1. Add a reference to the WindowsFormsIntegration library. In Visual Studio, you can open the Project menu, select “Add Reference,” and select the library from the .NET tab on the Add Reference dialog. In Expression Blend, you can open the Project menu, select Add Reference, and then browse to the library file. On my system, it’s installed at C:\Program Files\ Reference Assemblies\Microsoft\Framework\v3.0\WindowsFormsIntegration.dll. 2. Add a reference to the System.Windows.Forms.dll library. Again, in Visual Studio, you can use the Project menu’s Add Reference command and select the library from the resulting dialog. In Expression Blend, you can again use the Project menu’s Add Reference command and then browse to the library file. On my system, it’s installed at C:\Windows\Microsoft.NET\ Framework\v2.0.50727\System.Windows.Forms.dll. 3. Add a namespace declaration for the Windows Forms namespace to the top of the XAML file. The declaration should look something like this: xmlns:wf=”clr-namespace:System.Windows.Forms;assembly=System.Windows.Forms” Hope this helps.

                V.

                P Offline
                P Offline
                Pete OHanlon
                wrote on last edited by
                #7

                Be aware, though, that any theming you apply to your textboxes will not apply. Also, focus management in WPF is problematic enough without adding Winforms into the mix. I'd avoid this option altogether and use a native WPF version instead as there are plenty of freely available solutions and this is an unnecessary step.

                I have CDO, it's OCD with the letters in the right order; just as they ruddy well should be

                Forgive your enemies - it messes with their heads

                My blog | My articles | MoXAML PowerToys | Onyx

                V 1 Reply Last reply
                0
                • P Pete OHanlon

                  Be aware, though, that any theming you apply to your textboxes will not apply. Also, focus management in WPF is problematic enough without adding Winforms into the mix. I'd avoid this option altogether and use a native WPF version instead as there are plenty of freely available solutions and this is an unnecessary step.

                  I have CDO, it's OCD with the letters in the right order; just as they ruddy well should be

                  Forgive your enemies - it messes with their heads

                  My blog | My articles | MoXAML PowerToys | Onyx

                  V Offline
                  V Offline
                  V 0
                  wrote on last edited by
                  #8

                  MM didn't know that. Thanks, I'll keep that in mind.

                  V.

                  1 Reply Last reply
                  0
                  Reply
                  • Reply as topic
                  Log in to reply
                  • Oldest to Newest
                  • Newest to Oldest
                  • Most Votes


                  • Login

                  • Don't have an account? Register

                  • Login or register to search.
                  • First post
                    Last post
                  0
                  • Categories
                  • Recent
                  • Tags
                  • Popular
                  • World
                  • Users
                  • Groups