Thanks a ton, that worked for the String collection Editor which should do the trick. It doesn't work for my custom collection editor however. I can keep messing with it from here knowing that I can always fall back to the string collection editor.
Thanks again, Greg -----Original Message----- From: Discussion of advanced .NET topics. [mailto:[EMAIL PROTECTED] On Behalf Of Peter Ritchie Sent: Friday, February 24, 2006 11:14 To: [email protected] Subject: Re: [C#] System.Windows.Forms.ListBox - Items collection not holding data This works for me: public partial class UserControl : System.Windows.Forms.UserControl { private System.Windows.Forms.ListBox listBox1; [MergableProperty(false)] [System.ComponentModel.DesignerSerializationVisibility (DesignerSerializationVisibility.Content)] [Localizable(true)] [Editor ("System.Windows.Forms.Design.ListControlStringCollectionEditor, System.Design, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a", typeof (System.Drawing.Design.UITypeEditor))] public ListBox.ObjectCollection Items { get { return listBox1.Items; } } public UserControl() { InitializeComponent(); } } On Fri, 24 Feb 2006 10:44:37 -0500, Gregory Miley <[EMAIL PROTECTED]> wrote: >I have created a UserControl with a System.Windows.Forms.ListBox >control on it. The problem is, I cannot seem to modify the .Items >collection >(ListBox.ObjectCollection) in design-time when I create an instance of >my user control on another user control or form. I have tried working >around it several ways. One using > > >[DesignerSerializationVisibility(DesignerSerializationVisibility.Conten >t >)] > >I have a custom class that has a string Key, string Value, and string >ToString() override method. I tried creating a custom ItemCollection >and binding it to the ListBox DisplayMember and ValueMember and >modifying the underlying collection instance. I also wrote a custom >ItemCollectionEditor and applied it to my public Items property. > >So far I cannot get the data to persist in design-time. When I modify >the Items collection it allows me to properly add items as I have >defined with my editor (it even appeared to work correctly before I >wrote the editor and simply accessed the ListBox.Items property >directly), however once I build, it loses all information I had added. > >I noticed in the ListBox Class description, under remarks there is a >Note saying that ListBox, ComboBox, and CheckedListBox must have empty >string collections or they will be marked as readonly. I have no >initial data in there on the base class and my public Items property is >not greyed out as readonly. It simply does not hold data. I can provide >more information, and/or code samples if needed, I just didn't want to >send a bunch of junk right off in case there was a simple solution. =) =================================== This list is hosted by DevelopMentor(r) http://www.develop.com View archives and manage your subscription(s) at http://discuss.develop.com =================================== This list is hosted by DevelopMentorĀ® http://www.develop.com View archives and manage your subscription(s) at http://discuss.develop.com
