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

  • Home
  • SEARCH
  • 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 219069
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T18:48:37+00:00 2026-05-11T18:48:37+00:00

As I understood , The property grid is given an object which it can

  • 0

As I understood , The property grid is given an object which it can manipulate by extracting its Properties using reflections.

My problem is that I have a set of Parameters that is determined during run-time , thus I can’t staticly compose a class with properties to represent this set.

I have two idea in mind to solve this problem but both are complex and will probably consume lot of time , infact i will say they are not practical under my time constraints. One is to use Reflection Emit in order to define a class dynamically and the other is to dynamiclly build a C# source file and then compile it using CodeDom.

Can Property grid behave in a different manner( other then extracting the Properties of an object using reflections ) that can suite my problem?

If no do you know any other control that can do the job for me?

I want to say that the reason I went to the property grid from the begining was its ability to provide realy nice Data Retrieval UI for common types.For color you autometically get a palette , For dataTime you automatically have a nice calender. I would like to get those things automatically , If possible.

  • 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. Editorial Team
    Editorial Team
    2026-05-11T18:48:38+00:00Added an answer on May 11, 2026 at 6:48 pm

    Yes, PropertyGrid can display things other than just the compile-time properties, by using any of TypeConverter, ICustomTypeDescriptor or TypeDescriptionProvider to provide runtime pseudo-properties. Can you give an example of what your parameters look like? I should be able to provide an example…


    here’s a basic example (everything is string, etc) based on an earlier reply (related but different):

    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Windows.Forms;
    class PropertyBagPropertyDescriptor : PropertyDescriptor {
        public PropertyBagPropertyDescriptor(string name) : base(name, null) { }
        public override object GetValue(object component) {
            return ((PropertyBag)component)[Name];
        }
        public override void SetValue(object component, object value) {
            ((PropertyBag)component)[Name] = (string)value;
        }
        public override void ResetValue(object component) {
            ((PropertyBag)component)[Name] = null;
        }
        public override bool CanResetValue(object component) {
            return true;
        }
        public override bool ShouldSerializeValue(object component)
        { // *** this controls whether it appears bold or not; you could compare
          // *** to a default value, or the last saved value...
            return ((PropertyBag)component)[Name] != null;
        }
        public override Type PropertyType {
            get { return typeof(string); }
        }
        public override bool IsReadOnly {
            get { return false; }
        }
        public override Type ComponentType {
            get { return typeof(PropertyBag); }
        }
    }
    [TypeConverter(typeof(PropertyBagConverter))]
    class PropertyBag {
        public string[] GetKeys() {
            string[] keys = new string[values.Keys.Count];
            values.Keys.CopyTo(keys, 0);
            Array.Sort(keys);
            return keys;
        }
        private readonly Dictionary<string, string> values
            = new Dictionary<string, string>();
        public string this[string key] {
            get {
                string value;
                values.TryGetValue(key, out value);
                return value;
            }
            set {
                if (value == null) values.Remove(key);
                else values[key] = value;
            }
        }
    }
    // has the job of (among other things) providing properties to the PropertyGrid
    class PropertyBagConverter : TypeConverter {
        public override bool GetPropertiesSupported(ITypeDescriptorContext context) {
            return true; // are we providing custom properties from here?
        }
        public override PropertyDescriptorCollection GetProperties(ITypeDescriptorContext context, object value, System.Attribute[] attributes) {
            // get the pseudo-properties
            PropertyBag bag = (PropertyBag)value;
            string[] keys = bag.GetKeys();
            PropertyDescriptor[] props = Array.ConvertAll(
                keys, key => new PropertyBagPropertyDescriptor(key));
            return new PropertyDescriptorCollection(props, true);
        }
    }
    
    static class Program {
        [STAThread]
        static void Main() { // demo form app
            PropertyBag bag = new PropertyBag();
            bag["abc"] = "def";
            bag["ghi"] = "jkl";
            bag["mno"] = "pqr";
            Application.EnableVisualStyles();
            Application.Run(
                new Form {
                    Controls = { new PropertyGrid {
                        Dock = DockStyle.Fill,
                        SelectedObject = bag
                    }}
                });
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

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

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

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

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

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer This is most likely a bug in Python or your… May 13, 2026 at 12:36 am
  • Editorial Team
    Editorial Team added an answer You should set the tintColor of the UIToolbar object to… May 13, 2026 at 12:36 am
  • Editorial Team
    Editorial Team added an answer Well, here's one good one that I came up with… May 13, 2026 at 12:36 am

Related Questions

Trying to develop using MVVM: I have this Csla.PropertyStatus control that is created in
I'm using the WPF Grid to align objects, and ran into a rather glaring
I'm trying to open and read from a serial port using the System.IO.Ports.SerialPort class.
I am inserting a column in a DataGridView programmatically (i.e., not bound to any

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.