Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 75709
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T20:33:31+00:00 2026-05-10T20:33:31+00:00

How do you modify a propertygrid at runtime in every way? I want to

  • 0

How do you modify a propertygrid at runtime in every way? I want to be able to add and remove properties and add ‘dynamic types’, what I mean with that is a type that result in a runtime generated dropdown in the propertygrid using a TypeConverter.

I have actually been able to do both those things (add/remove properties and add dynamic type) but only separately not at the same time.

To implement the support to add and remove properties at runtime I used this codeproject article and modified the code a bit to support different types (not just strings).

private System.Windows.Forms.PropertyGrid propertyGrid1; private CustomClass myProperties = new CustomClass();  public Form1() {     InitializeComponent();      myProperties.Add(new CustomProperty('Name', 'Sven', typeof(string), false, true));     myProperties.Add(new CustomProperty('MyBool', 'True', typeof(bool), false, true));     myProperties.Add(new CustomProperty('CaptionPosition', 'Top', typeof(CaptionPosition), false, true));     myProperties.Add(new CustomProperty('Custom', '', typeof(StatesList), false, true)); //<-- doesn't work }  /// <summary> /// CustomClass (Which is binding to property grid) /// </summary> public class CustomClass: CollectionBase,ICustomTypeDescriptor {     /// <summary>     /// Add CustomProperty to Collectionbase List     /// </summary>     /// <param name='Value'></param>     public void Add(CustomProperty Value)     {         base.List.Add(Value);     }      /// <summary>     /// Remove item from List     /// </summary>     /// <param name='Name'></param>     public void Remove(string Name)     {         foreach(CustomProperty prop in base.List)         {             if(prop.Name == Name)             {                 base.List.Remove(prop);                 return;             }         }     } 

etc…

public enum CaptionPosition {     Top,     Left } 

My complete solution can be downloaded here.

It works fine when I add strings, bools or enums, but when I try to add a ‘dynamic type’ like StatesList it doesn’t work. Does anyone know why and can help me to solve it?

public class StatesList : System.ComponentModel.StringConverter {     private string[] _States = { 'Alabama', 'Alaska', 'Arizona', 'Arkansas' };      public override System.ComponentModel.TypeConverter.StandardValuesCollection     GetStandardValues(ITypeDescriptorContext context)     {         return new StandardValuesCollection(_States);     }      public override bool GetStandardValuesSupported(ITypeDescriptorContext context)     {         return true;     }      public override bool GetStandardValuesExclusive(ITypeDescriptorContext context)     {         return true;     } } 

The method of using a TypeConverter works fine when you don’t try to add the property at runtime, for example this code works without any problem, but I want to be able to do both.

Please take a look at my project. Thanks!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-10T20:33:32+00:00Added an answer on May 10, 2026 at 8:33 pm

    What you do, is adding StatesList (a TypeConverter) as a property.
    What you should do, is adding a property with StatesList as its TypeConverter.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 69k
  • Answers 69k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • added an answer The second is wrong ! You may use MyClass object;… May 11, 2026 at 12:28 pm
  • added an answer I have heard this works well. http://www.bdsoft.com/tools/stlfilt.html It is a… May 11, 2026 at 12:28 pm
  • added an answer You could create a sorted array using the same sort… May 11, 2026 at 12:28 pm

Related Questions

How do you test the usability of the user interfaces of your applications -
How do you create your own custom moniker (or URL Protocol) on Windows systems?
When you use a Windows Forms TextBox, the default number of tab stops (spaces)
In VS .NET, when you are selecting a folder for a project, a dialog

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.