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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T00:08:56+00:00 2026-05-28T00:08:56+00:00

I have an custom control that represents a grid; and implements another custom control.

  • 0

I have an custom control that represents a grid; and implements another custom control.
When opening this control in de designer, I am able to use the collection editor to set my collection. When saving; the designer successfully saves my collection.

However, when dropping this control on a form; it still (and should) expose(s) the collection property allowing me to modify the default values as i have defined in the other control.

However; when saving this designer; it also tries to store the predefined items in the collection; adding the default ones with every save.

What is the best way to solve this problem? I have attached a code sample.

Code sample where i have defined my collection:
GridPicture.cs

    [Category("Layout")]
    [DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
    [Editor(typeof(CollectionEditor), typeof(UITypeEditor))]
    public GridPictureColumnDefinitionCollection ColumnDefinitions
    {
        // The DesignerSerializationVisibility attribute instructs the design editor to serialize the contents of the collection to source code.
        // This will place all the code required to add the items to a collection variable of GridPictureColumnDefinitionCollection.
        get
        {
            return m_ColumnDefinitions;
        }
    }

Generated designer code of my first ‘implementation’ of this grid; Picture1.cs

        VGTest.GridPictureColumnDefinition gridPictureColumnDefinition1 = new VGTest.GridPictureColumnDefinition();
        VGTest.GridPictureColumnDefinition gridPictureColumnDefinition2 = new VGTest.GridPictureColumnDefinition();
        VGTest.GridPictureRowDefinition gridPictureRowDefinition1 = new VGTest.GridPictureRowDefinition();
        gridPictureColumnDefinition1.Auto = true;
        gridPictureColumnDefinition1.Value = 0F;
        gridPictureColumnDefinition2.Auto = true;
        gridPictureColumnDefinition2.Value = 0F;
        this.ColumnDefinitions.Add(gridPictureColumnDefinition1);
        this.ColumnDefinitions.Add(gridPictureColumnDefinition2);
        gridPictureRowDefinition1.Auto = true;
        gridPictureRowDefinition1.Value = 0F;
        this.RowDefinitions.Add(gridPictureRowDefinition1);

Code sample when i place this picture1 on another picture; picture2.cs: (Note that picture11 is the picture1, as it is the 1st of picture1 😉

VGTest.GridPictureColumnDefinition gridPictureColumnDefinition1 = new VGTest.GridPictureColumnDefinition();
            VGTest.GridPictureColumnDefinition gridPictureColumnDefinition2 = new VGTest.GridPictureColumnDefinition();
            VGTest.GridPictureColumnDefinition gridPictureColumnDefinition3 = new VGTest.GridPictureColumnDefinition();
            VGTest.GridPictureRowDefinition gridPictureRowDefinition1 = new VGTest.GridPictureRowDefinition(); 
// Some code removed that does the Auto and Value settings as above
            this.picture11.ColumnDefinitions.Add(gridPictureColumnDefinition1);
            this.picture11.ColumnDefinitions.Add(gridPictureColumnDefinition2);
            this.picture11.ColumnDefinitions.Add(gridPictureColumnDefinition3);

The picture2 control; when it regenerates the InitializeComponent() method; now adds the columndefinitions which i have added in picture1.

I have written this temporary fix for the problem:

{
    // This makes sure column definitions are only serialized when configured at a implementation of this GridPicture.
    // This is a Quick/Dirty fix for the following problem:
    // When MyPanel (:GridPicture) is put on PanelContainer(:Picture); the picture designer (re)serializes this each save.
    return this.GetType().BaseType.Name == typeof(Picture).Name;
}
  • 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-28T00:08:56+00:00Added an answer on May 28, 2026 at 12:08 am

    I was unable to find a better method. I have decided to stick with the solution below.

    {
        // This makes sure column definitions are only serialized when configured at a implementation of this GridPicture.
        // This is a Quick/Dirty fix for the following problem:
        // When MyPanel (:GridPicture) is put on PanelContainer(:Picture); the picture designer (re)serializes this each save.
        return this.GetType().BaseType.Name == typeof(Picture).Name;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a custom control that implements IPostBackEventHandler. Some client-side events invoke __doPostBack(controlID, eventArgs).
I have a custom control that inherits from WebControl and implements IValidator, but I
I have a custom control that inherits from .NET's CompositeControl class. This control overrides
I have a custom control that I've placed inside a cell of a grid.
I have a custom control that I use that has some (NSTextField *) NSCells
I have a custom control in my mater page that represents a menu, let's
I have a custom control that uses a designer I've inherited from ParentControlDesigner to
I have a custom control that exposes a property. When I set it using
I have a custom control that has the following prototype. Type.registerNamespace('Demo'); Demo.CustomTextBox = function(element)
I have a custom control that shows a value obtained from the database (the

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.