doesn't have one, set the Reset menuitem to disabled.
4. if the DefaultValueAttribute exists, get the current value of this
property and compare it with the default value, set the correct menu state.
5. to reset the value of this property, you may use
PropertyDescriptor.ResetValue method.
Here is a sample snippet, Hope it will be helpful :
<code>
private void contextMenu1_Popup(object sender, System.EventArgs e)
{
GridItem item = propertyGrid1.SelectedGridItem;
DefaultValueAttribute defValue =
item.PropertyDescriptor.Attributes[typeof (DefaultValueAttribute)] as
DefaultValueAttribute;
if (defValue != null && defValue.Value != null)
{
object obj =
item.PropertyDescriptor.GetValue (propertyGrid1.SelectedObject);
menuItem1.Enabled = !(obj.Equals (defValue.Value));
}
else menuItem1.Enabled = false;
menuItem2.Checked = propertyGrid1.HelpVisible;
}
private void menuItem2_Click(object sender, System.EventArgs e)
{
propertyGrid1.HelpVisible = ! propertyGrid1.HelpVisible;
menuItem2.Checked = propertyGrid1.HelpVisible;
}
private void menuItem1_Click(object sender, System.EventArgs e)
{
GridItem item = propertyGrid1.SelectedGridItem;
item.PropertyDescriptor.ResetValue (propertyGrid1.SelectedObject);
}
</code>
Does it solve your problem?
If you still have problem on it please be free to reply this thread.
Thanks!
Best regards,
Ying-Shen Yu [MSFT]
Microsoft Online Partner Support
Get Secure! -
www.microsoft.com/security
This posting is provided "AS IS" with no warranties and confers no rights.
This mail should not be replied directly, "online" should be removed before
sending.
.