protected void SetBrowsable(string property, bool value) { PropertyDescriptor descriptor = TypeDescriptor.GetProperties(this.GetType())[property]; BrowsableAttribute attribute = (BrowsableAttribute)descriptor.Attributes[typeof(BrowsableAttribute)]; Type gtype = attribute.GetType(); FieldInfo[] fields = attribute.GetType().GetFields(BindingFlags.NonPublic | BindingFlags.Instance); Debug.Assert(fields.Length == 1); FieldInfo fieldToChange = fields[0]; fieldToChange.SetValue(attribute, value); }
/// +=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+= /// <summary> /// Sets the readonly attribute on a property so the user cannot adjust if if /// it is not appropriate to the current operation mode /// </summary> /// <remarks> /// Credits: the basic mechanisim for performing this operation is derived /// from: http://www.codeproject.com/KB/tabs/ExploringPropertyGrid.aspx</remarks> private void SetPropertyBrowsableState(FileManager fileManagersObj, string propertyName, bool isNonBrowsable) { bool wantBrowsable; if (fileManagersObj == null) { return; } if ((propertyName == null) || (propertyName.Length == 0)) { return; } if (isNonBrowsable == true) { wantBrowsable = false; } else { wantBrowsable = true; } PropertyDescriptor descriptor = TypeDescriptor.GetProperties(fileManagersObj.GetType())[propertyName]; BrowsableAttribute attrib = (BrowsableAttribute)descriptor.Attributes[typeof(BrowsableAttribute)]; FieldInfo browsable = attrib.GetType().GetField("browsable", BindingFlags.NonPublic | BindingFlags.Instance); browsable.SetValue(attrib, wantBrowsable); }
PropertyGridProperty GetReadOnlyProperty(string propertyName, bool browsable = true) { if (!browsable) { PropertyDescriptor descriptor = TypeDescriptor.GetProperties(this.GetType())[propertyName]; ReadOnlyAttribute attribute = (ReadOnlyAttribute) descriptor.Attributes[typeof(ReadOnlyAttribute)]; FieldInfo fieldToChange = attribute.GetType().GetField("isReadOnly", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance); return(new PropertyGridProperty(attribute, fieldToChange)); } else { PropertyDescriptor descriptor = TypeDescriptor.GetProperties(this.GetType())[propertyName]; BrowsableAttribute attribute = (BrowsableAttribute) descriptor.Attributes[typeof(BrowsableAttribute)]; FieldInfo fieldToChange = attribute.GetType().GetField("browsable", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance); return(new PropertyGridProperty(attribute, fieldToChange)); } }
private static void HideProperty(Type type, string name) { PropertyDescriptor descriptor = TypeDescriptor.GetProperties(type)[name]; BrowsableAttribute attrib = (BrowsableAttribute)descriptor.Attributes[typeof(BrowsableAttribute)]; FieldInfo isBrow = attrib.GetType().GetField("browsable", BindingFlags.NonPublic | BindingFlags.Instance); isBrow?.SetValue(attrib, false); }
public static void ChangeBrowsableAttribute(this object obj, string fieldName, bool newState) { PropertyDescriptor descriptor = TypeDescriptor.GetProperties(obj.GetType())[fieldName]; BrowsableAttribute attribute = (BrowsableAttribute)descriptor.Attributes[typeof(BrowsableAttribute)]; FieldInfo fieldToChange = attribute.GetType().GetField("Browsable", BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.IgnoreCase); fieldToChange.SetValue(attribute, newState); }
public void SetVisible(String PropertyName, bool value) { PropertyDescriptor descriptor = TypeDescriptor.GetProperties(this.GetType())[PropertyName]; BrowsableAttribute attribute = (BrowsableAttribute)descriptor.Attributes[typeof(BrowsableAttribute)]; FieldInfo Browsable = attribute.GetType().GetField("browsable", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance); Browsable.SetValue(attribute, value); }
public static void SetBrowsable(object item, string propertyName, bool visible) { PropertyDescriptor descriptor = TypeDescriptor.GetProperties(item.GetType())[propertyName]; BrowsableAttribute attribute = (BrowsableAttribute)descriptor.Attributes[typeof(BrowsableAttribute)]; FieldInfo browsable = attribute.GetType().GetField("browsable", BindingFlags.NonPublic | BindingFlags.Instance); browsable.SetValue(attribute, visible); }
private void ShowProperty(string name, bool bShow = true) { PropertyDescriptor descriptor = TypeDescriptor.GetProperties(this.GetType()) [name]; BrowsableAttribute attrib = (BrowsableAttribute)descriptor.Attributes [typeof(BrowsableAttribute)]; FieldInfo isBrowsable = attrib.GetType().GetField("browsable", BindingFlags.NonPublic | BindingFlags.Instance); isBrowsable.SetValue(attrib, bShow); }
protected void SetBrowsable(string property, bool value) { PropertyDescriptor descriptor = TypeDescriptor.GetProperties(this.GetType())[property]; BrowsableAttribute attribute = (BrowsableAttribute)descriptor.Attributes[typeof(BrowsableAttribute)]; FieldInfo fieldToChange = attribute.GetType().GetField("browsable", BindingFlags.NonPublic | BindingFlags.Instance); fieldToChange.SetValue(attribute, value); }
public MQOUT(XmlNode dataModel, IView view) : base(dataModel, view) { PropertyDescriptor descriptor = TypeDescriptor.GetProperties(this.GetType())["Priority"]; BrowsableAttribute theDescriptorBrowsableAttribute = (BrowsableAttribute)descriptor.Attributes[typeof(BrowsableAttribute)]; FieldInfo isBrowsable = theDescriptorBrowsableAttribute.GetType().GetField("Browsable", BindingFlags.IgnoreCase | BindingFlags.NonPublic | BindingFlags.Instance); // Set the Descriptor's "Browsable" Attribute isBrowsable.SetValue(theDescriptorBrowsableAttribute, false); }
public void SetPropertyBrowsableAttributeValue(string _propertyName, bool value) { PropertyDescriptor descriptor = TypeDescriptor.GetProperties(this.GetType())[_propertyName]; if (descriptor != null) { BrowsableAttribute attrib = (BrowsableAttribute)descriptor.Attributes[typeof(BrowsableAttribute)]; FieldInfo isBrowsable = attrib.GetType().GetField("Browsable", BindingFlags.NonPublic | BindingFlags.Instance); isBrowsable.SetValue(attrib, value); } }
private void HideShowProperty(string property, bool show) { PropertyDescriptor descriptor = TypeDescriptor.GetProperties(this.GetType())[property]; BrowsableAttribute attrib = (BrowsableAttribute)descriptor.Attributes[typeof(BrowsableAttribute)]; FieldInfo isBrow = attrib.GetType().GetField("browsable", BindingFlags.NonPublic | BindingFlags.Instance); isBrow.SetValue(attrib, show); }
protected void ShowHide(string field, bool value) { try { PropertyDescriptor descriptor = TypeDescriptor.GetProperties(this.GetType())[field]; BrowsableAttribute theDescriptorBrowsableAttribute = (BrowsableAttribute)descriptor.Attributes[typeof(BrowsableAttribute)]; FieldInfo isBrowsable = theDescriptorBrowsableAttribute.GetType().GetField("Browsable", BindingFlags.IgnoreCase | BindingFlags.NonPublic | BindingFlags.Instance); isBrowsable.SetValue(theDescriptorBrowsableAttribute, value); } catch (Exception) { Console.WriteLine($"Show/Hide Issue for {field}"); } }
/// <summary> /// Set the Browsable property. /// NOTE: Be sure to decorate the property with [Browsable(true)] /// </summary> /// <param name="PropertyName">Name of the variable</param> /// <param name="bIsBrowsable">Browsable Value</param> public void setBrowsableProperty(string strPropertyName, bool bIsBrowsable) { // Get the Descriptor's Properties PropertyDescriptor theDescriptor = TypeDescriptor.GetProperties(this.GetType())[strPropertyName]; // Get the Descriptor's "Browsable" Attribute BrowsableAttribute theDescriptorBrowsableAttribute = (BrowsableAttribute)theDescriptor.Attributes[typeof(BrowsableAttribute)]; FieldInfo isBrowsable = theDescriptorBrowsableAttribute.GetType().GetField("Browsable", BindingFlags.IgnoreCase | BindingFlags.NonPublic | BindingFlags.Instance); // Set the Descriptor's "Browsable" Attribute isBrowsable.SetValue(theDescriptorBrowsableAttribute, bIsBrowsable); }
public RABBITIN(XmlNode dataModel, IView view) { this._node = dataModel; this.view = view; this.type = "RABBITDEFEX"; // The "Priority Propery is only for input, so make sure it is set correctly PropertyDescriptor descriptor = TypeDescriptor.GetProperties(this.GetType())["Priority"]; BrowsableAttribute theDescriptorBrowsableAttribute = (BrowsableAttribute)descriptor.Attributes[typeof(BrowsableAttribute)]; FieldInfo isBrowsable = theDescriptorBrowsableAttribute.GetType().GetField("Browsable", BindingFlags.IgnoreCase | BindingFlags.NonPublic | BindingFlags.Instance); // Set the Descriptor's "Browsable" Attribute isBrowsable.SetValue(theDescriptorBrowsableAttribute, true); }
public bool SetDescription(object _src, PropertyInfo _pi_src, object _dst, PropertyInfo _pi_dst) { BrowsableAttribute ba_src = Attribute.GetCustomAttribute(_pi_src, typeof(BrowsableAttribute)) as BrowsableAttribute; if (!ba_src.Browsable) { PropertyDescriptor pd = TypeDescriptor.GetProperties(_pi_dst.DeclaringType)[_pi_dst.Name]; BrowsableAttribute ba = (BrowsableAttribute)pd.Attributes[typeof(BrowsableAttribute)]; if (ba != null) { FieldInfo isBrowsable = ba.GetType().GetField("Browsable", BindingFlags.IgnoreCase | BindingFlags.NonPublic | BindingFlags.Instance); isBrowsable.SetValue(ba, false); } } return(true); }
public void SetView() { foreach (PropertyInfo pi in GetType().GetProperties()) { if (Attribute.GetCustomAttribute(pi, typeof(DynamicAttribute)) == null) { continue; } PropertyDescriptor pd = TypeDescriptor.GetProperties(pi.DeclaringType)[pi.Name]; BrowsableAttribute ba = (BrowsableAttribute)pd.Attributes[typeof(BrowsableAttribute)]; FieldInfo isBrowsable = ba.GetType().GetField("Browsable", BindingFlags.IgnoreCase | BindingFlags.NonPublic | BindingFlags.Instance); DisplayNameAttribute nm = (DisplayNameAttribute)pd.Attributes[typeof(DisplayNameAttribute)]; isBrowsable.SetValue(ba, DynamicEnable(nm.DisplayName)); } }
public Boolean control_browsable_attribute(PropertyDescriptor descriptor, Boolean flag) { Boolean ret; BrowsableAttribute attribute_descriptor = descriptor.Attributes[typeof(BrowsableAttribute)] as BrowsableAttribute; FieldInfo isBrowsable = attribute_descriptor.GetType().GetField("browsable", BindingFlags.NonPublic | BindingFlags.Instance); if (isBrowsable == null) { ret = false; } else { isBrowsable.SetValue(attribute_descriptor, flag); ret = true; } return(ret); }
public override Object StateChanged(string SelectedProperty, string newValue, Object ClassInstance, PropertyGrid SelectedPgrid) { // IState'inde SendPinBuffData propertyinin eventinde if (SelectedProperty == "SendPinBuffData") { string[] ExtensionStates = new string[] { "ExtensionStateNumber1", "ExtensionDescription1", "ExtensionType", "SendGenPurpData_extension", "SendOptionalDataAH", "SendOptionalDataIL", "SendOptionalDataQV", "SendOptionalData", "EMVCAMProcessingFlag", "ExtensionStateNumber2", "ExtensionDescription2", "OfflineDeclineNextState" }; bool Standarstatus = (newValue == "000" || newValue == "001") ? true : false; bool extensionstatus = (newValue == "128" || newValue == "129") ? true : false; if (!extensionstatus) { ExtensionStates = null; ExtensionStates = new string[] { "ExtensionStateNumber1", "ExtensionDescription1", "ExtensionType", "SendGenPurpData_extension", "SendOptionalDataAH", "SendOptionalDataIL", "SendOptionalDataQV", "SendOptionalData", "EMVCAMProcessingFlag", "ExtensionStateNumber2", "ExtensionDescription2", "OfflineDeclineNextState", "PerformEMVCAMProcessingFlag" }; } string VisibleProperty = "SendGenPurpData"; PropertyDescriptor theDescriptor = TypeDescriptor.GetProperties(ClassInstance.GetType())[VisibleProperty]; BrowsableAttribute theDescriptorBrowsableAttribute = (BrowsableAttribute)theDescriptor.Attributes[typeof(BrowsableAttribute)]; FieldInfo isBrowsable = theDescriptorBrowsableAttribute.GetType().GetField("Browsable", BindingFlags.IgnoreCase | BindingFlags.NonPublic | BindingFlags.Instance); isBrowsable.SetValue(theDescriptorBrowsableAttribute, Standarstatus); for (int i = 0; i < ExtensionStates.Length; i++) { VisibleProperty = ExtensionStates[i]; PropertyDescriptor theDescriptor1 = TypeDescriptor.GetProperties(ClassInstance.GetType())[VisibleProperty]; BrowsableAttribute theDescriptorBrowsableAttribute1 = (BrowsableAttribute)theDescriptor1.Attributes[typeof(BrowsableAttribute)]; FieldInfo isBrowsable1 = theDescriptorBrowsableAttribute1.GetType().GetField("Browsable", BindingFlags.IgnoreCase | BindingFlags.NonPublic | BindingFlags.Instance); isBrowsable.SetValue(theDescriptorBrowsableAttribute1, extensionstatus); } } if (SelectedProperty == "EMVCAMProcessingFlag") { string VisibleProperty = "PerformEMVCAMProcessingFlag"; bool Standarstatus = (newValue == "0") ? false : true; PropertyDescriptor theDescriptor = TypeDescriptor.GetProperties(ClassInstance.GetType())[VisibleProperty]; BrowsableAttribute theDescriptorBrowsableAttribute = (BrowsableAttribute)theDescriptor.Attributes[typeof(BrowsableAttribute)]; FieldInfo isBrowsable = theDescriptorBrowsableAttribute.GetType().GetField("Browsable", BindingFlags.IgnoreCase | BindingFlags.NonPublic | BindingFlags.Instance); isBrowsable.SetValue(theDescriptorBrowsableAttribute, Standarstatus); } return(FillStateFromPropertyGrid(ClassInstance, SelectedPgrid)); }
public void SetDescription(object _parent, PropertyInfo _pi) { De de = Attribute.GetCustomAttribute(_pi, typeof(De)) as De; if (de == null) { return; } HideAttribute hide = Attribute.GetCustomAttribute(_pi, typeof(HideAttribute)) as HideAttribute; if (hide != null) { return; } if (descs == null) { return; } PropertyDescriptor pd = TypeDescriptor.GetProperties(_pi.DeclaringType)[_pi.Name]; de = (De)pd.Attributes[typeof(De)]; string ckey = _parent.GetType().Name + "." + _pi.Name; Desc desc = descs[_parent.GetType().Name + "." + _pi.Name]; if (desc == null) { desc = new Desc(); } de.Acc = desc.accsess; de.Description = desc.description; BrowsableAttribute ba = (BrowsableAttribute)pd.Attributes[typeof(BrowsableAttribute)]; if (ba != null) { FieldInfo isBrowsable = ba.GetType().GetField("Browsable", BindingFlags.IgnoreCase | BindingFlags.NonPublic | BindingFlags.Instance); if (de.Browsable) { isBrowsable.SetValue(ba, desc.accsess.CheckUser(User.current)); } } return; }
public static void SetAttribute(string propertyName, string attributeInnerName, Type targetType, object value) { try { PropertyDescriptor descriptor = TypeDescriptor.GetProperties(targetType)[propertyName]; if (descriptor != null) { BrowsableAttribute attribute = (BrowsableAttribute)descriptor.Attributes[typeof(BrowsableAttribute)]; if (attribute != null) { FieldInfo fieldToChange = attribute.GetType().GetField(attributeInnerName, System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance); if (fieldToChange != null) { fieldToChange.SetValue(attribute, value); } } } } catch { } }
/// <summary> /// Updates the property grid. /// </summary> /// <param name="node">The node to be shown.</param> private void UpdatePropertyGrid(TreeNode node) { SunModelPart p = Utils.GetTreeNodeClass(node); string businessProcess = this.tabControlArea.SelectedTab.Text; BusinessProcess b = this.cmodel.GetBusinessProcess(businessProcess); if (p == SunModelPart.BusinessProcess) { this.propertyGridArea.SelectedObject = b; } else if (p == SunModelPart.Measure || p == SunModelPart.Dimension) { this.propertyGridArea.SelectedObject = node.Tag; } else if (p == SunModelPart.Attribute || p == SunModelPart.SharedNode) { PropertyDescriptorCollection props = TypeDescriptor.GetProperties(node.Tag.GetType()); foreach (PropertyDescriptor desc in props) { ReadOnlyAttribute roAttribute = (ReadOnlyAttribute) desc.Attributes[typeof(ReadOnlyAttribute)]; FieldInfo roFieldToChange = roAttribute.GetType().GetField("isReadOnly", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance); roFieldToChange.SetValue(roAttribute, (desc.Name == "UID")); BrowsableAttribute brAttribute = (BrowsableAttribute) desc.Attributes[typeof(BrowsableAttribute)]; FieldInfo brFieldToChange = brAttribute.GetType().GetField("browsable", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance); brFieldToChange.SetValue(brAttribute, (desc.Name != "Level1" && desc.Name != "X_position" && desc.Name != "Y_position" && ( p != SunModelPart.SharedNode || (p == SunModelPart.SharedNode && desc.Name != "CDAKey" && desc.Name != "ConvergedKey" && desc.Name != "Key")))); } this.propertyGridArea.SelectedObject = node.Tag; } else if (p == SunModelPart.SharedNodeReference) { PropertyDescriptorCollection props = TypeDescriptor.GetProperties((typeof(Level))); foreach (PropertyDescriptor desc in props) { ReadOnlyAttribute roAttribute = (ReadOnlyAttribute) desc.Attributes[typeof(ReadOnlyAttribute)]; FieldInfo roFieldToChange = roAttribute.GetType().GetField("isReadOnly", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance); roFieldToChange.SetValue(roAttribute, true); BrowsableAttribute brAttribute = (BrowsableAttribute) desc.Attributes[typeof(BrowsableAttribute)]; FieldInfo brFieldToChange = brAttribute.GetType().GetField("browsable", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance); brFieldToChange.SetValue(brAttribute, (desc.Name == "UID" || desc.Name == "CDAKey" || desc.Name == "ConvergedKey" || desc.Name == "Key")); } this.propertyGridArea.SelectedObject = node.Tag; } else { this.propertyGridArea.SelectedObject = node.Tag; } }
public void ShowHide(string field, bool value) { try { PropertyDescriptor descriptor = TypeDescriptor.GetProperties(GetType())[field]; BrowsableAttribute theDescriptorBrowsableAttribute = (BrowsableAttribute)descriptor?.Attributes[typeof(BrowsableAttribute)]; if (theDescriptorBrowsableAttribute == null) { return; } FieldInfo isBrowsable = theDescriptorBrowsableAttribute.GetType().GetField("Browsable", BindingFlags.IgnoreCase | BindingFlags.NonPublic | BindingFlags.Instance); isBrowsable.SetValue(theDescriptorBrowsableAttribute, value); } catch (Exception ex) { Debug.WriteLine($"Show/Hide Issue for {field}. {ex.Message}"); } if (!Parameters.SITAAMS) { try { PropertyDescriptor descriptor = TypeDescriptor.GetProperties(GetType())["FlightType"]; BrowsableAttribute theDescriptorBrowsableAttribute = (BrowsableAttribute)descriptor.Attributes[typeof(BrowsableAttribute)]; FieldInfo isBrowsable = theDescriptorBrowsableAttribute.GetType().GetField("Browsable", BindingFlags.IgnoreCase | BindingFlags.NonPublic | BindingFlags.Instance); isBrowsable.SetValue(theDescriptorBrowsableAttribute, false); } catch (Exception) { // NO-OP } try { PropertyDescriptor descriptor = TypeDescriptor.GetProperties(GetType())["FlightDataSource"]; BrowsableAttribute theDescriptorBrowsableAttribute = (BrowsableAttribute)descriptor.Attributes[typeof(BrowsableAttribute)]; FieldInfo isBrowsable = theDescriptorBrowsableAttribute.GetType().GetField("Browsable", BindingFlags.IgnoreCase | BindingFlags.NonPublic | BindingFlags.Instance); isBrowsable.SetValue(theDescriptorBrowsableAttribute, false); } catch (Exception) { // NO-OP } try { PropertyDescriptor descriptor = TypeDescriptor.GetProperties(GetType())["FlightSetFrom"]; BrowsableAttribute theDescriptorBrowsableAttribute = (BrowsableAttribute)descriptor.Attributes[typeof(BrowsableAttribute)]; FieldInfo isBrowsable = theDescriptorBrowsableAttribute.GetType().GetField("Browsable", BindingFlags.IgnoreCase | BindingFlags.NonPublic | BindingFlags.Instance); isBrowsable.SetValue(theDescriptorBrowsableAttribute, false); } catch (Exception) { // NO-OP } try { PropertyDescriptor descriptor = TypeDescriptor.GetProperties(GetType())["FlightSetTo"]; BrowsableAttribute theDescriptorBrowsableAttribute = (BrowsableAttribute)descriptor.Attributes[typeof(BrowsableAttribute)]; FieldInfo isBrowsable = theDescriptorBrowsableAttribute.GetType().GetField("Browsable", BindingFlags.IgnoreCase | BindingFlags.NonPublic | BindingFlags.Instance); isBrowsable.SetValue(theDescriptorBrowsableAttribute, false); } catch (Exception) { // NO-OP } try { PropertyDescriptor descriptor = TypeDescriptor.GetProperties(GetType())["Sequential"]; BrowsableAttribute theDescriptorBrowsableAttribute = (BrowsableAttribute)descriptor.Attributes[typeof(BrowsableAttribute)]; FieldInfo isBrowsable = theDescriptorBrowsableAttribute.GetType().GetField("Browsable", BindingFlags.IgnoreCase | BindingFlags.NonPublic | BindingFlags.Instance); isBrowsable.SetValue(theDescriptorBrowsableAttribute, false); } catch (Exception) { // NO-OP } try { PropertyDescriptor descriptor = TypeDescriptor.GetProperties(GetType())["RefreshFlight"]; BrowsableAttribute theDescriptorBrowsableAttribute = (BrowsableAttribute)descriptor.Attributes[typeof(BrowsableAttribute)]; FieldInfo isBrowsable = theDescriptorBrowsableAttribute.GetType().GetField("Browsable", BindingFlags.IgnoreCase | BindingFlags.NonPublic | BindingFlags.Instance); isBrowsable.SetValue(theDescriptorBrowsableAttribute, false); } catch (Exception) { // NO-OP } } }
protected void ChangeProvider() { fileFormat = Gom.DataManagerList.Name[iDataManager]; writable = Gom.DataManagerList.Writable[iDataManager]; if (!writable) { writeData = false; } millisecCompliant = Gom.DataManagerList.MillisecCompliant[iDataManager]; useMillisec = millisecCompliant; //custom properties var props = from p in typeof(GomRecorderIndicator).GetProperties() where p.GetCustomAttributes(typeof(Gom.SpecificTo), false).Length > 0 select new { PropertyName = p.Name, RecorderName = ((Gom.SpecificTo)(p.GetCustomAttributes(typeof(Gom.SpecificTo), false)[0])).Name }; foreach (var p in props) { PropertyDescriptor descriptor = TypeDescriptor.GetProperties(this.GetType())[p.PropertyName]; bool browsableFound = false; foreach (var att in descriptor.Attributes) { if (att.GetType() == typeof(BrowsableAttribute)) { browsableFound = true; break; } } if (browsableFound) { BrowsableAttribute browsable = (BrowsableAttribute)descriptor.Attributes[typeof(BrowsableAttribute)]; FieldInfo isBrowsable = browsable.GetType().GetField("browsable", BindingFlags.NonPublic | BindingFlags.Instance); if (!p.RecorderName.Contains(fileFormat)) { isBrowsable.SetValue(browsable, false); } else { isBrowsable.SetValue(browsable, true); } } } //writeData only if writable PropertyDescriptor descriptorwd = TypeDescriptor.GetProperties(this.GetType())["WriteData"]; ReadOnlyAttribute roattrib = (ReadOnlyAttribute)descriptorwd.Attributes[typeof(ReadOnlyAttribute)]; FieldInfo isReadOnly = roattrib.GetType().GetField("isReadOnly", BindingFlags.NonPublic | BindingFlags.Instance); if (!writable) { WriteData = false; isReadOnly.SetValue(roattrib, true); } else { isReadOnly.SetValue(roattrib, false); } //usemillisec only if millisec compliant PropertyDescriptor descriptorum = TypeDescriptor.GetProperties(this.GetType())["UseMillisec"]; BrowsableAttribute browsableum = (BrowsableAttribute)descriptorum.Attributes[typeof(BrowsableAttribute)]; FieldInfo fiUseMillisec = browsableum.GetType().GetField("browsable", BindingFlags.NonPublic | BindingFlags.Instance); if (millisecCompliant) { fiUseMillisec.SetValue(browsableum, true); } else { fiUseMillisec.SetValue(browsableum, false); } }