By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
445,885 Members | 1,445 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 445,885 IT Pros & Developers. It's quick & easy.

VS2005: Collection properties not serialised by designer on custom controls

P: n/a
I have developed a custom control that, among others, includes a property that is a collection of "Items".

If I place an instance of my control onto a CF form, I can view all of the properties correctly in the property grid and my collection appears with the ellipses ready to open the collection editor. Click on the ellipses and the editor opens correctly and I can add and remove items in the collection.

Unfortunately, the incorrect code is generated when I close the designer, an example is below ...
//
// switchboard
//
this.switchboard.DisabledItemAction = TechnicalDirect.Windows.Forms.SwitchboardDisabledI temAction.Hide;
this.switchboard.Dock = System.Windows.Forms.DockStyle.Fill;
this.switchboard.Font = new System.Drawing.Font("Arial", 12F, System.Drawing.FontStyle.Regular);
this.switchboard.ItemHeight = 48;
this.switchboard.Location = new System.Drawing.Point(0, 0);
this.switchboard.Name = "switchboard";
this.switchboard.SelectedIndex = 0;
this.switchboard.Size = new System.Drawing.Size(312, 192);
this.switchboard.TabIndex = 0;
this.switchboard.Click += new System.EventHandler(this.switchboard_Click);
//
// switchboardItem1
//
this.switchboardItem1.Image = ((System.Drawing.Image)(resources.GetObject("switc hboardItem1.Image")));
this.switchboardItem1.Location = new System.Drawing.Point(0, 0);
this.switchboardItem1.Name = "switchboardItem1";
this.switchboardItem1.Size = new System.Drawing.Size(200, 200);
this.switchboardItem1.TabIndex = 0;
this.switchboardItem1.Text = "Logon";
Whilst this code looks fine, it is actually missing the part where the SwitchboardItem instance is added to the SwitchboardItems collection of the Switchboard control ...
this.switchboard.SwitchboardItems.Add(this.switchb oardItem1);
Has anybody seen this before, and if so, can you point me toward what I may have done wrong? I have not implemented any custom designers and my DesignTimeAttributes.xmta file contains an entry for the control with only the DesktopCompatible attribute specified.

Thanks.
Jun 26 '06 #1
Share this Question
Share on Google+
1 Reply


P: n/a
For anybody else that sees this problem, the answer is to specify <DesignerSerializationVisibility>DesignerSerializa tionVisibility.Content</DesignerSerializationVisibility> within the <Property name=""> tag.

"Martin Robins" <martin dot robins at technicaldirect dot co dot uk> wrote in message news:ud**************@TK2MSFTNGP05.phx.gbl...
I have developed a custom control that, among others, includes a property that is a collection of "Items".

If I place an instance of my control onto a CF form, I can view all of the properties correctly in the property grid and my collection appears with the ellipses ready to open the collection editor. Click on the ellipses and the editor opens correctly and I can add and remove items in the collection.

Unfortunately, the incorrect code is generated when I close the designer, an example is below ...
//
// switchboard
//
this.switchboard.DisabledItemAction = TechnicalDirect.Windows.Forms.SwitchboardDisabledI temAction.Hide;
this.switchboard.Dock = System.Windows.Forms.DockStyle.Fill;
this.switchboard.Font = new System.Drawing.Font("Arial", 12F, System.Drawing.FontStyle.Regular);
this.switchboard.ItemHeight = 48;
this.switchboard.Location = new System.Drawing.Point(0, 0);
this.switchboard.Name = "switchboard";
this.switchboard.SelectedIndex = 0;
this.switchboard.Size = new System.Drawing.Size(312, 192);
this.switchboard.TabIndex = 0;
this.switchboard.Click += new System.EventHandler(this.switchboard_Click);
//
// switchboardItem1
//
this.switchboardItem1.Image = ((System.Drawing.Image)(resources.GetObject("switc hboardItem1.Image")));
this.switchboardItem1.Location = new System.Drawing.Point(0, 0);
this.switchboardItem1.Name = "switchboardItem1";
this.switchboardItem1.Size = new System.Drawing.Size(200, 200);
this.switchboardItem1.TabIndex = 0;
this.switchboardItem1.Text = "Logon";
Whilst this code looks fine, it is actually missing the part where the SwitchboardItem instance is added to the SwitchboardItems collection of the Switchboard control ...
this.switchboard.SwitchboardItems.Add(this.switchb oardItem1);
Has anybody seen this before, and if so, can you point me toward what I may have done wrong? I have not implemented any custom designers and my DesignTimeAttributes.xmta file contains an entry for the control with only the DesktopCompatible attribute specified.

Thanks.
Jun 28 '06 #2

This discussion thread is closed

Replies have been disabled for this discussion.