Displaying edit mask as 95.25% and value of 0.9525
-
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
-
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
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: ^_^
-
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: ^_^
-
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
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) -
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: ^_^
-
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) -
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: ^_^
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:
-
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:
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: ^_^
-
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
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) -
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: ^_^