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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T03:40:42+00:00 2026-05-19T03:40:42+00:00

I have a custom control with a generic list of custom types. This list

  • 0

I have a custom control with a generic list of custom types. This list is defined public:

[DesignerSerializationVisibility(DesignerSerializationVisibility.Content), Editor(typeof(ButtonPanelXEditor), typeof(UITypeEditor))]
public List<CompactButton> CompactButtons
{
    get { return _compactButtons; }
    set { _compactButtons = value; }
}

When I add this control to my form and build my project I get this error:

Error 1 Could not find a type for a name. The type name was ‘ButtonPanelX.CompactButton, ButtonPanelX, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null’. Line 127, position 5. D:\Projecten\ButtonPanelX\ButtonPanelX\Form1.resx 127 5 ButtonPanelX

When I use strings instead of custom objects, the desginer does save my list. CompactButton has the attribute [Serializable] and derives from ISerializable

What can I do to fix this?

Edit:

public class ButtonPanelXEditor : UITypeEditor
{
    public override UITypeEditorEditStyle GetEditStyle(System.ComponentModel.ITypeDescriptorContext context)
    {
        if (context != null && context.Instance != null)
            // We will use a window for property editing. 
            return UITypeEditorEditStyle.Modal;

        return base.GetEditStyle(context);
    }

    public override object EditValue(System.ComponentModel.ITypeDescriptorContext context,
        IServiceProvider provider, object value)
    {

        context.OnComponentChanging();

        ButtonPanel b = context.Instance as ButtonPanel;

        FooBar form = new FooBar();
        form.Buttons = b.CompactButtons;

        form.ShowDialog();

        b.CompactButtons = form.Buttons;

        b.DrawButtons();

        context.OnComponentChanged();

        return form.Buttons;
    }
}

EDIT 2:

[Serializable]
public partial class ButtonPanel : UserControl
{
    private ArrayList _compactButtons;

    public ButtonPanel()
    {
        InitializeComponent();

        _compactButtons = new ArrayList();

        AddButtons();

        this.Load += new EventHandler(ButtonPanel_Load);

    }

    void ButtonPanel_Load(object sender, EventArgs e)
    {
        DrawButtons();
    }


    [DesignerSerializationVisibility(DesignerSerializationVisibility.Content), Editor(typeof(ButtonPanelXEditor), typeof(UITypeEditor))]
    public ArrayList CompactButtons
    {
        get { return _compactButtons; }
    }

    public void DrawButtons()
    {
        baseButton1.Visible = ((CompactButton)_compactButtons[0]).Visible;
        baseButton2.Visible = ((CompactButton)_compactButtons[1]).Visible;
    }

    private void AddButtons()
    {
        /* Buttons baseButton1 and baseButton2 are created by the designer */

        CompactButton c = new CompactButton();
        c.Enabled = baseButton1.Enabled;
        c.Visible = baseButton1.Visible;
        c.Name = baseButton1.Name;

        CompactButton c2 = new CompactButton();
        c2.Enabled = baseButton2.Enabled;
        c2.Visible = baseButton2.Visible;
        c2.Name = baseButton2.Name;

        _compactButtons.Add(c);
        _compactButtons.Add(c2);
    }
}
  • 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-19T03:40:43+00:00Added an answer on May 19, 2026 at 3:40 am

    Instead of serializing your buttons to the resource file, you could try to serialize them to the code behind. For this you need to implement a custom TypeDescriptor for your CompactButton type and there handle convertion to an InstanceDescriptor. Look at How to Implement a TypeConverter. Example:

    [TypeConverter(typeof(CompactButtonTypeConverter))]
    public class CompactButton: ... {
      ...
    }
    
    public class CompactButtonTypeConverter: TypeConverter {
    
      public override bool CanConvertTo(ITypeDescriptorContext context, Type destinationType) {
        if (destinationType == typeof(InstanceDescriptor)) 
           return true;
        return base.CanConvertTo(context, destinationType);
      }
    
      public override object ConvertTo(ITypeDescriptorContext context, CultureInfo culture, object value, Type destinationType) {
        if (destinationType == typeof(InstanceDescriptor) && value is CompactButton) {
          // This assumes you have a public default constructor on your type.
          ConstructorInfo ctor = typeof(CompactButton).GetConstructor();
          if (ctor != null) 
             return new InstanceDescriptor(ctor, new object[0], false);
        }
        return base.ConvertTo(context, culture, value, destinationType);      
      }
    
    }
    

    For more information also see the InstanceDescriptor class.

    UPDATE: As for your UITypeEditor and the CompactButtons property, you do not need a setter. Change your CompactButtons property as follows:

    [DesignerSerializationVisibility(DesignerSerializationVisibility.Content), Editor(typeof(ButtonPanelXEditor), typeof(UITypeEditor))]
    public List<CompactButton> CompactButtons
    {
        get { return _compactButtons; } // _compactButtons must of course be initialized.
    }
    

    Then you could implement the EditValue method of UITypeEditor like so:

    public override object EditValue(System.ComponentModel.ITypeDescriptorContext context,
      IServiceProvider provider, object value) {
      if (context == null || provider == null)
        return null;
    
      var b = context.Instance as ButtonPanel;
      if (b == null)
        return value;
    
      var editorService = (IWindowsFormsEditorService)
        provider.GetService(typeof(IWindowsFormsEditorService));
      if (editorService == null)
        return null;
    
      // This constructor should copy the buttons in its own list.
      using (var form = new FooBar(b.CompactButtons)) {
        if (editorService.ShowDialog(form) == DialogResult.OK && context.OnComponentChanging()) {
          b.CompactButtons.Clear();
          b.CompactButtons.AddRange(form.Buttons);
          context.OnComponentChanged();
        }
      }
      return value;
    }
    

    If your editor form is not very specialized you could maybe try out the CollectionEditor.

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

Sidebar

Related Questions

I have found this example on StackOverflow: var people = new List<Person> { new
I have a project that adds elements to an AutoCad drawing. I noticed that
I have a script that appends some rows to a table. One of the
I have a new web app that is packaged as a WAR as part
I have several USB mass storage flash drives connected to a Ubuntu Linux computer
I have a snippet to create a 'Like' button for our news site: <iframe
I have a login.jsp page which contains a login form. Once logged in the
i have a input tag which is non editable, but some times i need
Let say I have the following desire, to simplify the IConvertible's to allow me
I am playing with TFS 2010, and am trying to setup a build process

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.