title: How to change the TypeConverter attribute of a property at runtime?
body: <p>I have a class created for use with the PropertyGrid control in a VB.Net application. One of the properties of the class is:</p>
  
  <pre><code>    Private _someProp As String
  
      &lt;Browsable(True), _
       BindableAttribute(False), _
       DesignOnly(False), _
       DescriptionAttribute("Some Property Description"), _
       TypeConverter(GetType(propList1)), _
       DisplayName("Some Property")&gt; _
      Public Property someProp() As String
          Get
              Return _someProp
          End Get
          Set(ByVal Value As String)
              _someProp = Value                
          End Set
      End Property
  </code></pre>
  
  <p><strong>I want to change the TypeConverter attribute of this property at run-time</strong>. I am currently changing other attributes(e.g. Read-only, Browsable) like this:</p>
  
  <pre><code>Dim descriptor As PropertyDescriptor = TypeDescriptor.GetProperties(Me.GetType)("someProp")
  Dim attrib_r As ReadOnlyAttribute = descriptor.Attributes(GetType(ReadOnlyAttribute))
  Dim isReadOnly As System.Reflection.FieldInfo = attrib_r.GetType.GetField("isReadOnly", Reflection.BindingFlags.NonPublic + Reflection.BindingFlags.Instance)
  isReadOnly.SetValue(attrib_r, True)
  </code></pre>
  
  <p>However, I am not able to apply a similar technique to change the TypeConverter attribute. The typeConv variable is 'Nothing' when I try this:</p>
  
  <pre><code>Dim descriptor As PropertyDescriptor = TypeDescriptor.GetProperties(Me.GetType)("someProp")
  Dim attrib As TypeConverterAttribute = descriptor.Attributes(GetType(TypeConverterAttribute))
  Dim typeConv As System.Reflection.FieldInfo = attrib.GetType.GetField("typeConverter", Reflection.BindingFlags.NonPublic + Reflection.BindingFlags.Instance)
  typeConv.SetValue(attrib, IIf(someCondition, GetType(propList1), GetType(propList2)))
  </code></pre>
  
  <p>ETA: <strong>The TypeConverter in this case is used to display a dropdown in the PropertyGrid, so that users can choose an appropriate value, instead of typing in one. I want to change this list at runtime.</strong></p>
  
  <p>ETA2: With the generous help of a contributor (who decided to delete the answer for some reason), my current position is that I do get a field in the typeConv variable, but I cannot change it. I get an error "Object of type 'System.RuntimeType' cannot be converted to type 'System.String'" on the typeConv.SetValue statement irrespective of the value I provide - GetType(propeList2) / GetType(propeList2).AssemblyQualifiedName / a random string</p>
  
  <pre><code>Dim typeConv As System.Reflection.FieldInfo = attrib.GetType.GetField("typeName", BindingFlags.Instance Or _
                                                         BindingFlags.Public Or _
                                                         BindingFlags.NonPublic Or _
                                                         BindingFlags.FlattenHierarchy)
  typeConv.SetValue(attrib, value)
  </code></pre>