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 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 74k
  • Answers 74k
  • 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 Unit structure looks a bit like the public/private sections… May 11, 2026 at 2:20 pm
  • added an answer You don't need to worry about retrieving the arguments and… May 11, 2026 at 2:20 pm
  • added an answer Multiple Record Sets in ASP.NET MVC Yep - most definately.… May 11, 2026 at 2:20 pm

Related Questions

I have a PropertyGrid on my form. My boss thinks it's ugly. Uncouth. Unsophisticated.
I have a strange bug, please, let me know if you have any clues
I have a PropertyGrid in my application that is used for editing arbitrary objects.
I have a class with a string property, having both a getter and a
I have a Property Grid in C#, loading up a 'PropertyAdapter' object (a basic

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.