Пример #1
0
 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);
         }
     }
 }
Пример #2
0
        // 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);
                }
            }
        }