using System.Windows.Forms;
using System.Collections.Generic;
namespace TestPropGrid
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
TestObject to = new TestObject();
propertyGrid1.SelectedObject = to;
}
private void propertyGrid1_PropertyValueChanged(object s, PropertyValueChangedEventArgs e)
{
MessageBox.Show(this, "save time!", "occurs only when property really changed", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
}
public class TestSubObject
{
public int SomeField { get; set; }
}
public class TestObject
{
public List<TestSubObject> TSO { get; set; } //event will not fire when items added or removed or elements edited
public int TestField { get; set; } //event fires when needed
public TestObject()
{
this.TSO = new List<TestSubObject>();
}
}
}
This is test code to show the problem. When I add members or edit their SomeField, the propertyGrid1_PropertyValueChanged doesn't fires, while I want to use it to save the item.
I understand that event isn't fired, because pointer to TSO actually didn't changed, but what I should do to know if it's time save editing item after such edits?
No comments:
Post a Comment