コード例 #1
0
ファイル: Form1.cs プロジェクト: yongyi781/CCTools
 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);
                }
            }
        }