I am making a custom control that implements multiple controls, one of them being a ComboBox.
I have the following code to edit the ComboBox's Items property.
vb.net Code:
Dim _items as Object() <Editor("System.Windows.Forms.Design.ListControlStringCollectionEditor, System.Design, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a", GetType(UITypeEditor)), MergableProperty(False), Category("CatData"), DesignerSerializationVisibility(DesignerSerializationVisibility.Content), Localizable(True), Description("ComboBoxItemsDescr")> _ Property Items() As System.Windows.Forms.ComboBox.ObjectCollection Get Return cmb.Items End Get Set(ByVal value As System.Windows.Forms.ComboBox.ObjectCollection) value.CopyTo(_items, 0) cmb.Items.Clear() cmb.Items.AddRange(_items) End Set End Property
That code does work, but it seems to me there may be a better way to do this. Any ideas?




Reply With Quote