Advertisement
Guest User

Untitled

a guest
Jul 24th, 2023
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.22 KB | None | 0 0
  1.  
  2. namespace PhotoSift
  3. {
  4.     /// <summary>
  5.     /// Contains all PhotoSift settings. Most attributes control appearance in the PropertyGrid in frmSettings.
  6.     /// </summary>
  7.     [Serializable]
  8.     [DefaultProperty("FileMode")]
  9.     public class AppSettings : GlobalizedObject
  10.     {
  11.         ...
  12.         // Key Folder group
  13.         [Category("Key Folders"), DisplayName("A"), LocalizedDescription("blablabla")]
  14.         [Editor(typeof(FolderNameEditor2), typeof(UITypeEditor))]
  15.         public string KeyFolder_A { get; set; }
  16.         [Category("Key Folders"), DisplayName("B"), LocalizedDescription("blablabla")]
  17.         [Editor(typeof(FolderNameEditor2), typeof(UITypeEditor))]
  18.         public string KeyFolder_B { get; set; }
  19.         [Category("Key Folders"), DisplayName("C"), LocalizedDescription("blablabla")]
  20.         [Editor(typeof(FolderNameEditor2), typeof(UITypeEditor))]
  21.         public string KeyFolder_C { get; set; }
  22.         [Category("Key Folders"), DisplayName("D"), LocalizedDescription("blablabla")]
  23.         [Editor(typeof(FolderNameEditor2), typeof(UITypeEditor))]
  24.         ....
  25.     }
  26. }
  27.  
  28. .....
  29. PropertyInfo Prop = ( typeof( AppSettings ) ).GetProperty( "KeyFolder_" + KeyName );
  30. Prop.SetValue(Prop.Name, "new value");
  31. .....
  32.  
  33. ERROR:
  34. System.Reflection.TargetException: 'Object does not match target type.'
  35.  
  36.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement