This is a migrated thread and some comments may be shown as answers.

NumericTextBox - Get Masked Text

5 Answers 40 Views
Input
This is a migrated thread and some comments may be shown as answers.
Joe
Top achievements
Rank 2
Joe asked on 18 Sep 2013, 01:51 AM
Hi,
How can I get the masked text from a RadNumericTextBox?
For example...

// RadTextBox
RadNumericTextBox rntb = new RadNumericTextBox();
rntb.NumberFormat.PositivePattern = "n%";
rntb.NumberFormat.DecimalDigits = 0;
rntb.MinValue = 0;
rntb.MaxValue = 100;
rntb.Text = 50; // Displays as "50%"
 
// How do I get "50%" into a label?
Label lbl = new Label();
lbl.Text = rntb.Text; // Only shows "50". I want to show "50%"

In the above example, how can I get the masked value "50%"?
TextWithLiterals would be great but only applies to RadMaskedTextBox. 

Thanks!

5 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 1
answered on 18 Sep 2013, 05:32 AM
Hi Joe,

The rntb.Text property always returns the text without the positive/negative pattern. Please have a look at the sample code I tried to extract the pattern which works fine at my end.

C#:
string pattern = rntb.NumberFormat.PositivePattern;
Label1.Text = rntb.Text + pattern[pattern.Length - 1];

Thanks,
Shinu.
0
Joe
Top achievements
Rank 2
answered on 18 Sep 2013, 12:13 PM
Perfect. Thanks Shinu!
0
Joe
Top achievements
Rank 2
answered on 18 Sep 2013, 12:18 PM
One related question...
That code works for a suffix such as the "%" symbol. How can I achieve the same effect for a prefix like "$" symbol?

For a prefix, the above code converts "$50" to "50n".

Thanks again!
0
Shinu
Top achievements
Rank 1
answered on 19 Sep 2013, 04:57 AM
Hi Joe,

Please check the following C# code.

C#:
rntb.NumberFormat.PositivePattern = "$n";

string pattern = rntb.NumberFormat.PositivePattern;
Label1.Text = pattern[0] + rntb.Text;

Thanks,
Shinu
0
Joe
Top achievements
Rank 2
answered on 19 Sep 2013, 12:13 PM
Thanks again Shinu
Tags
Input
Asked by
Joe
Top achievements
Rank 2
Answers by
Shinu
Top achievements
Rank 1
Joe
Top achievements
Rank 2
Share this question
or