Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Windows.Forms;
- using System.ComponentModel;
- using System.Collections;
- namespace LeCombo // I already had a MyCombo
- {
- // show this one in the toolbox
- [ToolboxItem(true)]
- public class myComboBox : mimComboBox
- {
- public myComboBox()
- {
- Items = new object();
- items = new myItems(this);
- }
- // keep VS from trying to serialize the old one
- [Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
- new public object Items { get; set; } // this hides the real Items
- // ToDo: "items" doesnt look anything like a collection to VS even with
- // the attributes. The Collection editor loads, but nothing is serialized
- // Also the original ComboBox SmartTags are still trying to load the original editor
- // which suprises me; those should be able to be modified with a new UIDesigner
- // the real UITypeEditor is internal. Use the simple string collection
- [DesignerSerializationVisibility(DesignerSerializationVisibility.Content),
- Localizable(true),
- Editor("System.Windows.Forms.Design.StringCollectionEditor, System.Design", "System.Drawing.Design.UITypeEditor, System.Drawing"),
- MergableProperty(false)]
- public myItems items {get; set; }
- // trying to get serialization to work
- private bool ShouldSerializeitems()
- {
- return items.Count > 0;
- }
- private void Resetitems()
- {
- items = new myItems(this);
- }
- public class myItems // this is the custom Items classwith all necessary methods etc..
- {
- // this doesnt need to be public - VS is serializing it.
- private mimComboBox parentCB;
- public myItems(myComboBox parent)
- {
- parentCB = parent; // reference to the outer class
- }
- // converted to private var
- //public mimComboBox parentCB { get; set; } // the man-in-the-middle
- // all your methods..
- public int Add(object o) // one example of a custom method
- {
- // add your item-added event here
- return parentCB.Items_.Add(o);
- }
- // one of many many properties to provide..
- public int Count { get { return parentCB.Items_.Count; } }
- }
- }
- // hide from toolbox
- [ToolboxItem(false)]
- public class mimComboBox : ComboBox
- {
- public ObjectCollection Items_;
- public mimComboBox()
- {
- Items_ = Items;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement