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 107481
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T01:45:39+00:00 2026-05-11T01:45:39+00:00

I have a PropertyGrid on my form. My boss thinks it’s ugly. Uncouth. Unsophisticated.

  • 0

I have a PropertyGrid on my form. My boss thinks it’s ugly. Uncouth. Unsophisticated.

He wants a nice, neat, clean form. Here’s the catch: One of the properties is a collection of our home-grown objects. He likes the collection editor for this collection.

I know I can build my own collection editor. But is there a clean, simple solution to save me a few hours of coding, such that I can create and use a Collection editor directly without using the property grid?

  • 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-11T01:45:39+00:00Added an answer on May 11, 2026 at 1:45 am

    You can get this functionality from the UITypeEditor (via TypeDescriptor), but it isn’t trivial – you need to set up an IServiceProvider, an IWindowsFormsEditorService, and ideally an ITypeDescriptorContext – quite a bit of faff. It might be simpler to do it by hand if you aren’t familiar with those tools.

    Alternatively – take a look at SmartPropertyGrid.NET, an alternative to PropertyGrid.


    Update: here’s a working example… definitely non-trivial, but feel free to steal the code. It only works for modal editors, not drop-down. It also isn’t a great example of ‘separation of concerns’. The MyHelper class is the interesting one.

    using System; using System.Collections.Generic; using System.ComponentModel; using System.Drawing.Design; using System.Windows.Forms; using System.Windows.Forms.Design; class Foo {     public Foo() { Bars = new List<Bar>(); }     public List<Bar> Bars { get; private set; } } class Bar {     public string Name { get; set; }     public DateTime DateOfBirth { get; set; } } static class Program {     [STAThread]     static void Main()     {         Foo foo = new Foo();         Bar bar = new Bar();         bar.Name = 'Fred';         bar.DateOfBirth = DateTime.Today;         foo.Bars.Add(bar);         Application.EnableVisualStyles();         using(Form form = new Form())         using (Button btn = new Button())         {             form.Controls.Add(btn);             btn.Text = 'Edit';             btn.Click += delegate             {                 MyHelper.EditValue(form, foo, 'Bars');             };             Application.Run(form);         }     } }  class MyHelper : IWindowsFormsEditorService, IServiceProvider, ITypeDescriptorContext {     public static void EditValue(IWin32Window owner, object component, string propertyName) {         PropertyDescriptor prop = TypeDescriptor.GetProperties(component)[propertyName];         if(prop == null) throw new ArgumentException('propertyName');         UITypeEditor editor = (UITypeEditor) prop.GetEditor(typeof(UITypeEditor));         MyHelper ctx = new MyHelper(owner, component, prop);         if(editor != null && editor.GetEditStyle(ctx) == UITypeEditorEditStyle.Modal)         {             object value = prop.GetValue(component);             value = editor.EditValue(ctx, ctx, value);             if (!prop.IsReadOnly)             {                 prop.SetValue(component, value);             }         }     }     private readonly IWin32Window owner;     private readonly object component;     private readonly PropertyDescriptor property;     private MyHelper(IWin32Window owner, object component, PropertyDescriptor property)     {         this.owner = owner;         this.component = component;         this.property = property;     }     #region IWindowsFormsEditorService Members      public void CloseDropDown()     {         throw new NotImplementedException();     }      public void DropDownControl(System.Windows.Forms.Control control)     {         throw new NotImplementedException();     }      public System.Windows.Forms.DialogResult ShowDialog(System.Windows.Forms.Form dialog)     {         return dialog.ShowDialog(owner);     }      #endregion      #region IServiceProvider Members      public object GetService(Type serviceType)     {         return serviceType == typeof(IWindowsFormsEditorService) ? this : null;     }      #endregion      #region ITypeDescriptorContext Members      IContainer ITypeDescriptorContext.Container     {         get { return null; }     }      object ITypeDescriptorContext.Instance     {         get { return component; }     }      void ITypeDescriptorContext.OnComponentChanged()     {}      bool ITypeDescriptorContext.OnComponentChanging()     {         return true;     }      PropertyDescriptor ITypeDescriptorContext.PropertyDescriptor     {         get { return property; }     }      #endregion } 
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 59k
  • Answers 59k
  • 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 I would suggest that your best bet is to install… May 11, 2026 at 9:00 am
  • added an answer You should set attribute userpassword. May 11, 2026 at 9:00 am
  • added an answer To be honest, I'm not really sure the codes that… May 11, 2026 at 9:00 am

Related Questions

I have a PropertyGrid on my form. My boss thinks it's ugly. Uncouth. Unsophisticated.
I have a Windows application that uses a .NET PropertyGrid control. Is it possible
I have a Property Grid in C#, loading up a 'PropertyAdapter' object (a basic
I have a web-service that I will be deploying to dev, staging and production.
I have a .Net desktop application with a TreeView as one of the UI
I have a Queue<T> object that I have initialised to a capacity of 2,
I have a complete XML document in a string and would like a Document
I have a regex that is going to end up being a bit long
I have a custom validation function in JavaScript in a user control on a
I have a (potentially dumb) question about the C++ STL. When I make a

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.