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. C#
  4. Displaying edit mask as 95.25% and value of 0.9525

Displaying edit mask as 95.25% and value of 0.9525

Scheduled Pinned Locked Moved C#
regexquestion
10 Posts 3 Posters 3 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.
  • J Offline
    J Offline
    J Cod3r
    wrote on last edited by
    #1

    Hi, I am using a regular expression (100|\s*(\d{0,2})((\.|\,)(\d{2,4}))?\s*\%?\s*) to display a percentage correctly on a property. The RegEx works 100% for displaying the correct value visually. But after the user has entered the value on the property i.e. 95.25% I would like to retrieve a value of 0.9525 without writing code on the property. Would I be able to do this by setting either the DisplayFormat or EditMask attribute to something else? Thanks :-D

    P D 2 Replies Last reply
    0
    • J J Cod3r

      Hi, I am using a regular expression (100|\s*(\d{0,2})((\.|\,)(\d{2,4}))?\s*\%?\s*) to display a percentage correctly on a property. The RegEx works 100% for displaying the correct value visually. But after the user has entered the value on the property i.e. 95.25% I would like to retrieve a value of 0.9525 without writing code on the property. Would I be able to do this by setting either the DisplayFormat or EditMask attribute to something else? Thanks :-D

      P Offline
      P Offline
      Programm3r
      wrote on last edited by
      #2

      Hi, :) I think this will help you: Percent mask - Developer Express Inc.[^], well I hope so ... :jig: Kind regards

      The only programmers that are better those C# programmers are those who code in 1's and 0's :bob:

      :)Programm3r My Blog: ^_^

      J 1 Reply Last reply
      0
      • P Programm3r

        Hi, :) I think this will help you: Percent mask - Developer Express Inc.[^], well I hope so ... :jig: Kind regards

        The only programmers that are better those C# programmers are those who code in 1's and 0's :bob:

        :)Programm3r My Blog: ^_^

        J Offline
        J Offline
        J Cod3r
        wrote on last edited by
        #3

        Nee jou wetter dit werk nie, dankie vir die post Jannes

        P 1 Reply Last reply
        0
        • J J Cod3r

          Hi, I am using a regular expression (100|\s*(\d{0,2})((\.|\,)(\d{2,4}))?\s*\%?\s*) to display a percentage correctly on a property. The RegEx works 100% for displaying the correct value visually. But after the user has entered the value on the property i.e. 95.25% I would like to retrieve a value of 0.9525 without writing code on the property. Would I be able to do this by setting either the DisplayFormat or EditMask attribute to something else? Thanks :-D

          D Offline
          D Offline
          DaveyM69
          wrote on last edited by
          #4

          Can't you just strip the % sign then divide by 100?

          Dave
          BTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)
          Visual Basic is not used by normal people so we're not covering it here. (Uncyclopedia)

          J 1 Reply Last reply
          0
          • J J Cod3r

            Nee jou wetter dit werk nie, dankie vir die post Jannes

            P Offline
            P Offline
            Programm3r
            wrote on last edited by
            #5

            Ek het probeer ... :bob: Kan jy nie net een of ander conversion op die ding doen nie, of is dit meer as dit? Groete

            The only programmers that are better those C# programmers are those who code in 1's and 0's :bob:

            :)Programm3r My Blog: ^_^

            J 1 Reply Last reply
            0
            • D DaveyM69

              Can't you just strip the % sign then divide by 100?

              Dave
              BTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)
              Visual Basic is not used by normal people so we're not covering it here. (Uncyclopedia)

              J Offline
              J Offline
              J Cod3r
              wrote on last edited by
              #6

              That would require me to write code on that layer, something i want to avoid. I want to keep all formatting related issues within the same layer

              D 1 Reply Last reply
              0
              • P Programm3r

                Ek het probeer ... :bob: Kan jy nie net een of ander conversion op die ding doen nie, of is dit meer as dit? Groete

                The only programmers that are better those C# programmers are those who code in 1's and 0's :bob:

                :)Programm3r My Blog: ^_^

                J Offline
                J Offline
                J Cod3r
                wrote on last edited by
                #7

                Dit is meer as dit. Die property het drie attributes nl EditMask, EditMaskType en DisplayFormat. Jy moet EditMask en EditMaskType saam gebruik m.a.w jy se vir EditMask watter tiepe Mask jy gebruik nl enum { Simple, RegEx }. MSDN se ek behoord {0:P4} (P/p = Percentage) RegEx te gebruik maar dit werk ook nie reg nie. :confused:

                P 1 Reply Last reply
                0
                • J J Cod3r

                  Dit is meer as dit. Die property het drie attributes nl EditMask, EditMaskType en DisplayFormat. Jy moet EditMask en EditMaskType saam gebruik m.a.w jy se vir EditMask watter tiepe Mask jy gebruik nl enum { Simple, RegEx }. MSDN se ek behoord {0:P4} (P/p = Percentage) RegEx te gebruik maar dit werk ook nie reg nie. :confused:

                  P Offline
                  P Offline
                  Programm3r
                  wrote on last edited by
                  #8

                  Sjoe, dis is omtrent 'n mond vol. Ek sal rond kyk maar ek is self nie seker nie. Sal jou 'n mail drop as ek iets vind. :cool:

                  The only programmers that are better those C# programmers are those who code in 1's and 0's :bob:

                  :)Programm3r My Blog: ^_^

                  J 1 Reply Last reply
                  0
                  • J J Cod3r

                    That would require me to write code on that layer, something i want to avoid. I want to keep all formatting related issues within the same layer

                    D Offline
                    D Offline
                    DaveyM69
                    wrote on last edited by
                    #9

                    You're going to have to write code somewhere or you can't change the behavior. The easiest way when you have two properties that are the same essentially (apart from how they are displayed or their type etc) is to make one the master and the other the slave. For example - Text and Value properties, Value being the master.

                    private int m_Value;
                    pubilc string Text
                    {
                    get
                    {
                    int result = Value;
                    // Recalculate if needed here - ToDo
                    return string.Format("your format", result);
                    }
                    set
                    {
                    // Validate/Strip here - ToDo
                    int result;
                    int.TryParse(value, out result);
                    Value = result;
                    }
                    }
                    public int Value
                    {
                    get { return m_Value; }
                    set
                    {
                    m_Value = value;
                    // Raise event here - ToDo
                    }
                    }

                    Dave
                    BTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)
                    Visual Basic is not used by normal people so we're not covering it here. (Uncyclopedia)

                    1 Reply Last reply
                    0
                    • P Programm3r

                      Sjoe, dis is omtrent 'n mond vol. Ek sal rond kyk maar ek is self nie seker nie. Sal jou 'n mail drop as ek iets vind. :cool:

                      The only programmers that are better those C# programmers are those who code in 1's and 0's :bob:

                      :)Programm3r My Blog: ^_^

                      J Offline
                      J Offline
                      J Cod3r
                      wrote on last edited by
                      #10

                      thanks

                      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