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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T16:22:33+00:00 2026-05-26T16:22:33+00:00

I’m trying to edit complex objects in a PropertyGrid control. I add the ExpandableObjectConverter

  • 0

I’m trying to edit complex objects in a PropertyGrid control. I add the ExpandableObjectConverter (or my own subclass when I need it) as the TypeConverter and it works fine.

The one thing I can’t seem to figure out is this. The object itself will have its .ToString() representation next to it in the Grid. Then when I expand the object the attributes have the same. All can be editable. I want to disable editing of the ToString() object field, but keep the attributes editable.

So in the PropertyGrid it would look like this;

+ Color      {(R,G,B,A) = (255,255,255,255)}  --uneditable
     Alpha   255                              --editable
     Blue    255                              --editable
     Green   255                              --editable
     Red     255                              --editable

So far I haven’t found a way to do this. If I try to make it ReadOnly the entire object becomes read only. If I specify my own ExpandableObjectConverter and state it cannot convert from a string, if the string is edited in the PropertyGrid it will still try to cast and then fail.

I essentially just want it so I can stop end users from editing the string and forcing them to edit the individual attributes instead, so that I don’t have to write a string parser for every single class.

Is this possible, or is there another way of doing this I just haven’t thought of?

  • 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-26T16:22:33+00:00Added an answer on May 26, 2026 at 4:22 pm

    This seems to do the trick:

    [TypeConverter(typeof (Color.ColorConverter))]
    public struct Color
    {
        private readonly byte alpha, red, green, blue;
        public Color(byte alpha, byte red, byte green, byte blue)
        {
            this.alpha = alpha;
            this.red = red;
            this.green = green;
            this.blue = blue;
        }
        public byte Alpha { get { return alpha; } }
        public byte Red { get { return red; } }
        public byte Green { get { return green; } }
        public byte Blue { get { return blue; } }
        public override string ToString()
        {
            return string.Format("{{(R,G,B,A) = ({0},{1},{2},{3})}}", Red, Green, Blue, Alpha);
        }
        private class ColorConverter : ExpandableObjectConverter
        {
            public override bool GetCreateInstanceSupported(ITypeDescriptorContext context)
            {
                return true;
            }
            public override object CreateInstance(ITypeDescriptorContext context, IDictionary propertyValues)
            {
                return new Color((byte)propertyValues["Alpha"], (byte)propertyValues["Red"],
                                 (byte) propertyValues["Green"], (byte) propertyValues["Blue"]);
            }
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I need to clean up various Word 'smart' characters in user input, including but
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I need a function that will clean a strings' special characters. I do NOT
I'm trying to use string.replace('’','') to replace the dreaded weird single-quote character: ’ (aka
I'm trying to create an if statement in PHP that prevents a single post
I have thousands of HTML files to process using Groovy/Java and I need to

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.