• 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 5 years, 10 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:

  • .NET Core Version History | Release History of .NET Core
  • What is string interpolation in C#
  • What Is The Use Of Volatile Keyword In C#
  • Get System IP Address Using C#
  • SQL Server Interview Question and Answers

Primary Sidebar

Recent 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 ?
Log In
Increase Your Leadership Skills, Influence, and Power with Top Leadership courses starting at just $11.99.

Recent Posts

  • .NET Core Version History | Release History of .NET Core
  • What is string interpolation in C#
  • What Is The Use Of Volatile Keyword In C#
  • Get System IP Address Using C#
  • SQL Server Interview Question and Answers
  • C# Fixed Size Buffer
  • OWIN in ASP.NET Core| What is OWIN in .NET?
  • C# Version History | C# Evolution and Features
  • What is ASP.NET Core Module
  • C# 3d array

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 ?

Forums

  • .NET Framework
  • ASP.NET
  • C#
  • SQL

Recent 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