public void SelectPropertyByName(string propertyName)
{
propertiesPanel.Focus();
// The property grid provides no RootGridItem property,
// so we must find it manually
GridItem rootItem = propertiesPanel.propertiesGrid.SelectedGridItem;
while (rootItem.GridItemType != GridItemType.Root)
{
rootItem = rootItem.Parent;
}
foreach (GridItem item in rootItem.GridItems)
{
if ((item.GridItemType == GridItemType.Property) && (item.Label == propertyName))
{
item.Select();
return;
}
// search within categories too
foreach (GridItem subItem in item.GridItems)
{
if ((subItem.GridItemType == GridItemType.Property) && (subItem.Label == propertyName))
{
subItem.Select();
return;
}
}
}
}