Given that the selected PropertyGrid is Age:
SetCategoryLabelViaReflection(MyPropertyGrid.SelectedGridItem.Parent, MyPropertyGrid.SelectedGridItem.Parent.Label, "New Category Label");
Where SetCategoryLabelViaReflection() is defined as follows:
private void SetCategoryLabelViaReflection(GridItem category, string oldCategoryName, string newCategoryName) { try { Type t = category.GetType(); FieldInfo f = t.GetField("name", BindingFlags.NonPublic | BindingFlags.Instance); if (f.GetValue(category).Equals(oldCategoryName)) { f.SetValue(category, newCategoryName); } } catch (Exception ex) { System.Diagnostics.Trace.Write("Failed Renaming Category: " + ex.ToString()); } }
As for the software installation of the selected item whose parent category you want to change; There are a number of simple solutions. Google "Set focus to a specific PropertyGrid."
David MacDermot May 10 '12 at 20:16 2012-05-10 20:16
source share