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

MaskedEdit and SpinEditor

1 Answer 51 Views
MaskedEditBox
This is a migrated thread and some comments may be shown as answers.
Paul
Top achievements
Rank 1
Paul asked on 14 Sep 2014, 05:41 PM
Hi,

I need to be able to work with Nullable Doubles for these types of editors.  I've migrated from Infragistics to Telerik.  Infragistics has a nice Spin Editor in their masked edit editor which I am missing here. 

However, I am having trouble with Bindings and using nulls.  In my scenario, I have added the masked edit and spinner to a form.I have created the following class to bind to:

class MyClass : INotifyPropertyChanged
{
 private double? _summit; public event PropertyChangedEventHandler PropertyChanged;
 public double? Summit
 {
  get { return _summit; }
  set { _summit = value; OnPropertyChanged("Summit"); }
 } private double? _spinMe;
 public double? SpinMe
 {
  get { return _spinMe; }
  set { _spinMe = value; OnPropertyChanged("SpinMe"); }
 }
 
 protected void OnPropertyChanged(string name)
 {
  if (PropertyChanged != null)
  {
   PropertyChanged(this, new PropertyChangedEventArgs(name));
  }
 }
}

I am declaring a form field as follows:
MyClass myclassinstance = new MyClass();

I am calling the following in form load:
myclassinstance.Summit = 123.987;
myclassinstance.SpinMe = 101.21;
this.radMaskedEditBox1.DataBindings.Add("Value", myclassinstance, "Summit", false, DataSourceUpdateMode.OnValidation);
this.radSpinEditor1.DataBindings.Add("Value", myclassinstance, "SpinMe", false, DataSourceUpdateMode.OnValidation);

I have a button that displays the values when clicked.When the form shows, the masked edit for summit shows 123.987.  The spin editor shows 0.00.
When I click the button, this shows the 2 values as initialized - 123.987 and 101.21.
If I blank the spin then it reverts to 0.00.  Clicking the button shows the value as 101.21.
If I blank the masked edit and click on the button the value is still 123.987.

If I type a value into the spin edit then I need to understand how I can use binding with these nullable doubles correctly.

I can't see any nice Telerik examples of these and thought the community may benefit and I need help ASAP - I thought without opening a support case.  Appologies if I have missed anything.

Thanks

Andez

1 Answer, 1 is accepted

Sort by
0
Dimitar
Telerik team
answered on 17 Sep 2014, 11:32 AM
Hi Andez,

Thank you for writing.

In order to bind to nullable values you should change your bindings as follows:
this.radMaskedEditBox1.DataBindings.Add("Value", myclassinstance, "Summit", true, DataSourceUpdateMode.OnPropertyChanged,0);
this.radSpinEditor1.DataBindings.Add("Value", myclassinstance, "SpinMe", true, DataSourceUpdateMode.OnPropertyChanged,0);

I hope this helps. Should you have any other questions do not hesitate to ask.
 
Regards,
Dimitar
Telerik
 
Check out Telerik Analytics, the service which allows developers to discover app usage patterns, analyze user data, log exceptions, solve problems and profile application performance at run time. Watch the videos and start improving your app based on facts, not hunches.
 
Tags
MaskedEditBox
Asked by
Paul
Top achievements
Rank 1
Answers by
Dimitar
Telerik team
Share this question
or