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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T03:34:01+00:00 2026-06-03T03:34:01+00:00

I have a class: public class Filter { public Filter (string name, string value)

  • 0

I have a class:

public class Filter
{
    public Filter (string name, string value)
    {
        Name = name;
        Value = value;
    }

    public string Name {get; private set;}
    public string Value {get; set;}
}

And a collection class:

public class FilterCollection : Collection<Filter>
{
   // code elided
}

My component class:

public class MyComponent : Component
{
    // ...

    [Editor(typeof(FilterEditor), typeof(UITypeEditor))]
    [DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
    public FilterCollection Filters { get; set; }

    // ...
}

The problem is that the collection is not serialized correctly by the designer.

I’m sure I’m missing something but I don’t know what.

ADDITIONAL INFO

What I would like the designer.cs file to have is something along the following:

myComponent.Filters.Add (new Filter ("some name", "some value"));
myComponent.Filters.Add (new Filter ("other name", "other value"));

Is this feasible?

  • 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-06-03T03:34:03+00:00Added an answer on June 3, 2026 at 3:34 am

    Ok, problem solved.

    I needed to use a TypeConverter for my Filter class:

    internal class FilterConverter : TypeConverter
    {
        public override bool CanConvertTo (ITypeDescriptorContext context, Type destinationType)
        {
            return destinationType == typeof(InstanceDescriptor) || base.CanConvertTo (context, destinationType);
        }
    
        public override object ConvertTo (ITypeDescriptorContext context, CultureInfo culture, object value, Type destinationType)
        {
            if (destinationType == typeof(InstanceDescriptor) && value is Filter)
            {
                ConstructorInfo constructor = typeof (Filter).GetConstructor (new[] {typeof (string), typeof (string)});
    
                var filter = value as Filter;
                var descriptor = new InstanceDescriptor (constructor, new[] {filter.Name, filter.Value}, true);
    
                return descriptor;
            }
            return base.ConvertTo (context, culture, value, destinationType);
        }
    }
    

    The converter is then added to the Filter class like so:

    [TypeConverter(typeof(FilterConverter))]
    public class Filter
    {
        // ...
    }
    

    The important thing to note here is the creation of an instance descriptor with the required parameters for the Filter constructor. Also, you need to set the last parameter (isComplete) of the InstanceDescriptor constructor to true.

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

Sidebar

Related Questions

If I have this structure: public class Parent { public string Name{get; set;} public
I have this class: public MyClass { public void initialize(Collection<String> data) { this.data =
I have such class public unsafe class EigenSolver { public double* aPtr {get; private
Hi i have a EntityObject like this public class Adm{ private String id; private
I have a servlet like this: @WebServlet(/a/path) @WebInitParam(name=name, value=name_value) public class MyServlet extends HttpServlet
I have following class public class ButtonChange { private int _buttonState; public void SetButtonState(int
I have this class: public static class CsvWriter { private static StreamWriter _writer =
I have a class: public class User { public virtual int Id { get;
I have a class called Person - public class Person implements Nameable { private
I have class A: public B { ...} vector<A*> v; I want to do

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.