How to detect change on property of selectedObject

Hi friends of Syncfusion,

I need to do some calculations when the user make changes on any property of a selectedObject of the property grid. How can i detect or intercept this change/update?

Thanks in advance!!!
Eduardo.

5 Replies

VR Vijayalakshmi Roopkumar Syncfusion Team June 13, 2018 10:18 AM UTC

Hi Eduardo

Thank you for contacting Syncfusion Support.

From your update, we come to know that you want to indicate which property has been changed , for this you can use the SelectedPropertyItemChanged event. The same has been depicted in the below table:

Code:
C# 
private void abmPropertyGrid_SelectedPropertyItemChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) 
{ 
MessageBox.Show("PropertyName"+(e.NewValue as PropertyItem).DisplayName.ToString(), "Value"+ (e.NewValue as PropertyItem).Value.ToString()); 
} 


Please find the sample from following location for your reference

Samplehttp://www.syncfusion.com/downloads/support/forum/138092/ze/Wpf_Propertygrid1073620409 

Please try this solution and let us know if it is helpful.

Regards
Vijayalakshmi V.R. 



ED Eduardo June 14, 2018 01:12 AM UTC

Thanks but this is not what i am asking for.

The event SelectedPropertyItemChanged is raised when i move from one property-item to another one.

I want an event that is raised when i change the VALUE of a property-item.

Waiting for your answer, thanks.


VR Vijayalakshmi Roopkumar Syncfusion Team June 14, 2018 11:15 AM UTC

Hi Eduardo

In order to detect when the value changed of any properties in the propertygrid ,you can detect it by getting the type of each property editor and invoke the event respectively. Please find the below code:
 
Code Example:C# 

void _PropertyGrid_SelectedPropertyItemChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) 
        { 
            PropertyGrid prop = d as PropertyGrid; 
           if(prop.SelectedPropertyItem != null) 
           { 
               object typeinstance = prop.SelectedPropertyItem.PropertyEditor.GetType(); 
            
               if(typeinstance.ToString() == "Syncfusion.Windows.Shared.IntegerTextBox") 
               { 
                   IntegerTextBox property = prop.SelectedPropertyItem.PropertyEditor as IntegerTextBox; 
                   if(property != null) 
                   { 
                       property.ValueChanged += property_ValueChanged; 
                   } 
               } 
               else if(typeinstance.ToString() == "System.Windows.Controls.TextBox") 
               { 
                   TextBox property = prop.SelectedPropertyItem.PropertyEditor as TextBox; 
                   if (property != null) 
                   { 
                       property.TextChanged += property_TextChanged; 
                   } 
               } 
 
               else if (typeinstance.ToString() == "System.Windows.Controls.ComboBox") 
               { 
                   ComboBox property = prop.SelectedPropertyItem.PropertyEditor as ComboBox; 
                   if (property != null) 
                   { 
                       property.SelectionChanged += property_SelectionChanged; 
                   } 
               } 
              
           } 
        } 
 
        void property_SelectionChanged(object sender, SelectionChangedEventArgs e) 
        { 
            ComboBox instance = sender as ComboBox; 
            foreach(var item in instance.Items) 
            { 
                
                MessageBox.Show(item.ToString()); 
            } 
        } 
 
        void property_TextChanged(object sender, TextChangedEventArgs e) 
        { 
              MessageBox.Show(e.Source.ToString()); 
        } 
 
        void property_ValueChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) 
        { 
            MessageBox.Show(e.NewValue.ToString()); 
        } 

 
  
The same has been demonstrated in the following sample and please download it from following location:


Sample: http://www.syncfusion.com/downloads/support/directtrac/138092/ze/PROPER~11163595773.zip 


Please try this solution and let us know if it is helpful.

Regards
Vijayalakshmi V.R. 



FR Francis October 19, 2019 09:24 AM UTC

I am trying to download the last sample, but without success.


Can you please let the link available again?


KP Kanniyappan Panneer Selvam Syncfusion Team October 21, 2019 07:01 AM UTC

Hi Francis, 
 
Thanks for your update. 
 
Please find the sample below and let us know if you have any further queries on this. 
 
 
Regards, 
Kanniyappan P 


Loader.
Up arrow icon