• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar

Dotnet Stuff

  • Home
  • Articles
  • Tutorials
  • Forums
  • Career Advice
  • Jobs
  • .NET FAQs
  • News
  • Privacy Policy

How To Show Hide Properties Dynamically In Propertygrid?

Home › Forums › C# › How To Show Hide Properties Dynamically In Propertygrid?

Tagged: Dynamic PropertyGrid

  • This topic has 0 replies, 1 voice, and was last updated 6 years, 5 months ago by Rajeev.
Viewing 1 post (of 1 total)
  • Author
    Posts
  • October 3, 2016 at 1:16 pm #221
    Rajeev
    Keymaster

    In my current C# project I have to hide and show properties in Propertygrid according to the value selection user makes for another property in property grid.I am facing issues in adding this dynamic behavior using the PropertyGrid control.Is it possible to dynamically set Visible property for a property Item in propertygrid in C#.NET winforms project.

    Answer is yes, We can set the browsable attribute of a property to true or false dynamically to make it visible or invisible. Once sample code snippet is below,

    public void ModifyBrowsableAttribute(string attribute, object value)
    {
    var descriptorProp = TypeDescriptor.GetProperties(GetType())[attribute];
    var theAttribute = (BrowsableAttribute)descriptorProp.Attributes[typeof(BrowsableAttribute)];
    var isBrowsable = theAttribute.GetType().GetField(“browsable”, BindingFlags.NonPublic |         BindingFlags.Instance);
    isBrowsable.SetValue(theAttribute, value);
    }

  • Author
    Posts
Viewing 1 post (of 1 total)
  • You must be logged in to reply to this topic.
Log In

Related Posts:

  • OWIN Authentication in .NET Core
  • Serializing and Deserializing JSON using Jsonconvertor in C#
  • What is CAP Theorem? | What is Brewer’s Theorem?
  • SOLID -Basic Software Design Principles
  • What is Interface Segregation Principle (ISP) in SOLID Design Principles?

Primary Sidebar

Recent Posts

  • OWIN Authentication in .NET Core
  • Serializing and Deserializing JSON using Jsonconvertor in C#
  • What is CAP Theorem? | What is Brewer’s Theorem?
  • SOLID -Basic Software Design Principles
  • What is Interface Segregation Principle (ISP) in SOLID Design Principles?
  • What is Single Responsibility Principle (SRP) in SOLID Design Priciples?
  • What is the Liskov Substitution Principle(LSP) in SOLID Design Principles?
  • What Depency inversion principle(DIP) in SOLID Design Priciples?
  • What is the Open Closed Principle in SOLID Design Principles?
  • What is the Difference Between Database Partitioning and Sharding?

Recent Forum Topics

  • What is the Difference Between IEnumerable and IQueryable in C#
  • How to remove Header of the XML file in C#?
  • What is DBMS?
  • What is RDBMS?
  • What is asp net framework ?

© Copywright 2017 Dotnetstuffs All Rights Reserved