title: How can I set BrowseAttribute true or false in properties in propertygrid c#?
body: <blockquote>
    <p><strong>Possible Duplicate:</strong><br>
    <a href="https://stackoverflow.com/questions/4690481/conditional-browsable-attribute">Conditional &ldquo;Browsable&rdquo; Attribute</a>  </p>
  </blockquote>
  
  
  
  <p>I define <code>AppSettings</code> class that have a few properties. In my form, When I <code>click Button1</code>, I want show property 1 and 2(1,2 is show, Other properties are hide or not displayed), When <code>click Button2</code>, I want show property 2 and 3(1 is hide, 2,3 are show, Other properties are hide or not displayed), How can I do it ?</p>
  
  <pre><code>public class AppSettings
  {
      [BrowsableAttribute(true), CategoryAttribute("Document Settings"), DefaultValueAttribute(true)]
      public bool SaveOnClose{ get; set; }
  
      [BrowsableAttribute(true), CategoryAttribute("Global Settings"), ReadOnlyAttribute(true), DefaultValueAttribute("Welcome to AppDev!")]
      public string GreetingText { get; set; }
  
      [BrowsableAttribute(true), DescriptionAttribute("The rate in milliseconds that the text will repeat."), CategoryAttribute("Global Settings"), DefaultValueAttribute(10)]
      public int MaxRepeatRate { get; set; }
  
      [BrowsableAttribute(true), CategoryAttribute("Global Settings"), DefaultValueAttribute(4)]
      public int ItemsInMRUList { get; set; }
  
      [BrowsableAttribute(true), DefaultValueAttribute(false)]
      public bool SettingsChanged { get; set; }
  
      [BrowsableAttribute(true), CategoryAttribute("Version"), DefaultValueAttribute("1.0"), ReadOnlyAttribute(true)]
      public string AppVersion { get; set; }
  }
  </code></pre>
  
  <p>I want change dynamically <code>BrowseAttribute</code> to true or false. How can I do it ?</p>
  
  <p>Form code is :</p>
  
  <pre><code>AppSettings AppSet = new AppSettings();
  
  AppSet.AppVersion = "2.3";
  AppSet.SaveOnClose = true;
  AppSet.GreetingText = "Welcome to Dar!";
  AppSet.ItemsInMRUList = 4;
  AppSet.MaxRepeatRate = 10;
  AppSet.SettingsChanged = false;
  
  ...
  
  propertyGrid1.SelectedObject = AppSet;
  </code></pre>
  
  <p>this change has error:</p>
  
  <pre><code>public static bool state = true;
  BrowsableAttribute(state)
  </code></pre>
  
  <p>error: </p>
  
  <blockquote>
    <p>An attribute argument must be a constant expression, typeof expression
    or array creation expression of an attribute parameter type</p>
  </blockquote>