日期:2014-05-17  浏览次数:21181 次

求助:PropertyGrid的ResetSelectedProperty没有重置到初始值,怎么破?
            
            PropertyGrid _propGrid = new PropertyGrid();

            _propGrid.SelectedObject = obj;
            _propGrid.Size = tabControl_prop.Size;

            _propGrid.PropertySort = PropertySort.NoSort;

            tabControl_prop.TabPages[tabControl_prop.TabPages.Count - 1].Controls.Add(_propGrid);


属性页是自定义的obj,怎样能够放弃对属性页的编辑改动,恢复到赋给SelectedObject时候obj所具有的值。
我使用ResetSelectedProperty没有效果,还有其他方法实现这个功能么?
求助!
PropertyGrid

------解决方案--------------------
没这个功能。

ResetSelectedProperty工作的前提是,这个属性有一个DefualtValue 的 Attribute

http://msdn.microsoft.com/zh-cn/library/system.componentmodel.defaultvalueattribute(v=vs.90).ASPX