private void SoftRefreshPropertyGrid(PropertyGrid propertyGrid) { if (propertyGrid.GetType().GetField("peMain", BindingFlags.NonPublic | BindingFlags.Instance).GetValue(propertyGrid) is GridItem peMain) { var refreshMethod = peMain.GetType().GetMethod("Refresh"); if (refreshMethod != null) { refreshMethod.Invoke(peMain, null); propertyGrid.Invalidate(true); } } }
// https://stackoverflow.com/questions/288893/how-to-prevent-scroll-on-refresh-in-a-propertygrid public static void SoftRefreshPropertyGrid(PropertyGrid propertyGrid) { var peMain = propertyGrid.GetType().GetField("peMain", BindingFlags.NonPublic | BindingFlags.Instance).GetValue(propertyGrid) as System.Windows.Forms.GridItem; if (peMain != null) { var refreshMethod = peMain.GetType().GetMethod("Refresh"); if (refreshMethod != null) { refreshMethod.Invoke(peMain, null); propertyGrid.Invalidate(true); } } }