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

PropertyGrid Custom TypeEditor INotifyPropertyChanged

1 Answer 112 Views
PropertyGrid
This is a migrated thread and some comments may be shown as answers.
Andrea
Top achievements
Rank 1
Andrea asked on 14 Jul 2014, 01:19 PM
Hi, 

several properties of the object attached to my RadPropertyGrid are of a custom type "DPDouble", which wraps some functionality around a double value.
In order to show and edit properties of this type in the Grid, I have implemented a custom type editor DPDoubleEditorNew which is called like this:

01.void RequestEditors(object sender, Telerik.WinControls.UI.PropertyGridEditorRequiredEventArgs e)
02.{
03.    PropertyGridItem item = e.Item as PropertyGridItem;
04.    if (item.PropertyType == typeof(DPDouble))
05.    {
06.        e.EditorType = typeof(DPDoubleEditorNew);
07.    }
08. 
09.}



And the editor is based on this code:

   public class DPDoubleEditorNew : BaseTextBoxEditor
{
 
    private DPDouble internalvalue;
 
    public override object Value
    {
        get
        {
           
            BaseTextBoxEditorElement element = this.EditorElement as BaseTextBoxEditorElement;
             
            double myval;
            if(double.TryParse(element.Text,out myval))
            {
                internalvalue.SetValueAuto(myval);
            }
             
            return internalvalue;
        }
        set
        {
             
            internalvalue = (DPDouble)value;
            base.Value = internalvalue;
        }
    }
 
}


Basically you see that I keep a pointer to the DPDouble object and when the editor is done I use the SetValueAuto as setter function.
This works fine, but although the bound object subscribes to INotifyPropertyChanged interface, and I raise the PropertyChanged event in the SetValueAuto setter function, my grid seems unable to catch the event.

My object has the following event

public event PropertyChangedEventHandler PropertyChanged;
 
    public void RaisePropertyChanged(String info)
    {
        if (PropertyChanged != null)
        {
            PropertyChangedEventArgs args = new PropertyChangedEventArgs(info);
            PropertyChanged(this, args);
        }
    }


The RaisePropertyChanged gets called, but although my grid subscribes to the PropertyChanged event 

PropertyGrid.PropertyChanged += new PropertyChangedEventHandler(PropertyGrid_PropertyChanged);

the handler is never called.
It seems like the INotifyPropertyChanged is notifying somebody else than my grid.

Do you have any suggestions?

1 Answer, 1 is accepted

Sort by
0
Yoan
Telerik team
answered on 17 Jul 2014, 09:24 AM
Hi Andrea,

Our RadPropertyGrid does not have its own PropertyChanged event. This is why I am not sure that I can understand your question. May I ask you to provide a sample project illustrating your scenario. This will helps us to assist you better.
 
I'm looking forward to hearing from you.

Regards,
Yoan
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
PropertyGrid
Asked by
Andrea
Top achievements
Rank 1
Answers by
Yoan
Telerik team
Share this question
or