|
-
Jan 28th, 2010, 04:38 AM
#1
Thread Starter
Frenzied Member
[RESOLVED] Designer, List inside List, drops data
Hi All,
This is a fairly circumstantial question, so I'm not sure if anyone will be able to help, but maybe someone has come across this before.
Well I have a custom user control that has a property that is a List of objects, that object type also has a List inside of it. When I use this control at design time, I can use the designer to create items in the main list, and all the items and their properties stay set just as you'd expect, but the list property inside of those items (so the sublist) drops data (I mean, I can open a designer for these sublists and add items just fine.. but when I save the list is simply lost).
I looked into some code for creating a collection class for the main list in hope that this would help (as opposed to just List<type>) but all the examples seem to be old code I presume because we now have generics to do this (which normally works fine until this strange little quirk).
So hopefully you understood all that and have some suggestions 
Code in question of a user control
Code:
[Serializable]
public struct ToolboxGroup
{
public string Name { get; set; }
public List<ToolboxItem> Items { get; set; }
}
[Serializable]
public struct ToolboxItem
{
public string DisplayName { get; set; }
public string Name { get; set; }
public Image Icon { get; set; }
}
public List<ToolboxGroup> items = new List<ToolboxGroup>();
public List<ToolboxGroup> Groups { get { return items; } set { items = value; } }
-
Jan 28th, 2010, 04:40 AM
#2
Thread Starter
Frenzied Member
Re: Designer, List inside List, drops data
d'oh I posted in the wrong forum. will ask a mod to move to c# (not that it matters much in this question but still)
-
Jan 28th, 2010, 05:38 AM
#3
Re: Designer, List inside List, drops data
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Jan 28th, 2010, 06:03 AM
#4
Thread Starter
Frenzied Member
Re: Designer, List inside List, drops data
Ok well, I seem to have rectified the problem.
I changed them from structs to classes, and split the lists into a private and public in order to give them a default value. I also created some constructors for both. Now the designer seems to have no trouble at all.
eg:
Code:
private List<ToolboxItem> items = new List<ToolboxItem>();
public List<ToolboxItem> Items { get { return items; } set { items = value; } }
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|