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

Problem with Text Format

3 Answers 99 Views
TextBox
This is a migrated thread and some comments may be shown as answers.
Fabien
Top achievements
Rank 2
Fabien asked on 21 Nov 2008, 09:37 AM
Hi,

I need to use this mask '##0.#'
So if I launch my application it will display '___._'. That's correct.

The problem is when I change the Value.

By default : (on debug)
  this.RadMaskedEditBox_Test.Mask "##0.#" string
  this.RadMaskedEditBox_Test.Value "" object {string}
  this.RadMaskedEditBox_Test.Text "___._" string

Value to set :
  Singleton.Instance.MarketGrowthRate 1.4 decimal

 


this
.RadMaskedEditBox_Test.Value = Singleton.Instance.MarketGrowthRate.ToString(this.RadMaskedEditBox_Test.Mask);  
 

 

 

 


After this code :
  this.RadMaskedEditBox_Test.Value "14" object {string}
  this.RadMaskedEditBox_Test.Text "14_._" string
It doesn't set 1.4 in the value and "__1.4" in the text.

And I can't use something like n1 because I must have a maxlength. (999.9)

Thanks for your help



 

3 Answers, 1 is accepted

Sort by
0
Fabien
Top achievements
Rank 2
answered on 21 Nov 2008, 10:11 AM
I discovered an other problem with events:

 

// Not fired  
this.RadMaskedEditBox_Test.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.RadMaskedEditBox_Test_KeyPress);     
this.RadMaskedEditBox_Test.KeyUp += new System.Windows.Forms.KeyEventHandler(this.RadMaskedEditBox_Test_KeyUp);   
 
/* Not cancelled */   
private void RadMaskedEditBox_Test_ValueChanging(object sender, System.ComponentModel.CancelEventArgs e)  
{  
 if (RadMaskedEditBox_Test.Text.Length > 13)  
 e.Cancel = true;  
}  
  

 

it's not working...

 

 

 

 

 

0
Fabien
Top achievements
Rank 2
answered on 21 Nov 2008, 03:02 PM

I didn't find a way to resolve the Mask problem but... I found a way to catch the Keypress event.

on form constructor :

 

 

 
this.RadMaskedEditBox_Test.MaskedEditBoxElement.TextBoxItem.KeyPress += new KeyPressEventHandler(RadMaskedEditBox_Test_KeyPress);   
 
 

 

 

and 

 

 

private void RadMaskedEditBox_Test_KeyPress(object sender, KeyPressEventArgs e)   
{  
 if (this.RadMaskedEditBox_Test.Text.Length == 5)   
  e.Handled = true;   
}  
 
 

 

 

0
Boyko Markov
Telerik team
answered on 24 Nov 2008, 04:30 PM
Hi Fabien,

I wasn't able to reproduce the issue with the ValueChanging event. Here is the code I used:

  1. this.radMaskedEditBox1.ValueChanging += new CancelEventHandler(radMaskedEditBox1_ValueChanging);
     
  2. void radMaskedEditBox1_ValueChanging(object sender, CancelEventArgs e)
        {
            e.Cancel = true;
        }

When I set the Cancel property to true, the editing is being canceled. The maskType property is Standard. Could you please give me more detailed instructions on how to replicate the reported bug?

I'm looking forward to your reply.


Kind regards,
Boyko Markov
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Tags
TextBox
Asked by
Fabien
Top achievements
Rank 2
Answers by
Fabien
Top achievements
Rank 2
Boyko Markov
Telerik team
Share this question
or