public CustomPropertyDescriptor(CustomProperty myProperty, Attribute[] attrs) : base(myProperty.Name, attrs) { if (myProperty == null) { oCustomProperty = null; } else { oCustomProperty = myProperty; } }
public virtual int Add(CustomProperty value) { List.Insert(0, value); return(0); }
public virtual int Add(CustomProperty value) { List.Insert(0, value); return 0; }
[RefreshProperties(RefreshProperties.All)] public override object EditValue(System.ComponentModel.ITypeDescriptorContext context, System.IServiceProvider provider, object value) { if (context == null || provider == null || context.Instance == null) { return(base.EditValue(provider, value)); } oEditorService = (System.Windows.Forms.Design.IWindowsFormsEditorService)provider.GetService(typeof(IWindowsFormsEditorService)); if (oEditorService != null) { // Get the Back reference to the Custom Property CustomProperty.CustomPropertyDescriptor oDescriptor = (CustomProperty.CustomPropertyDescriptor)context.PropertyDescriptor; CustomProperty cp = (CustomProperty)oDescriptor.CustomProperty; // Declare attributes UIListboxDatasource datasource; UIListboxValueMember valuemember; UIListboxDisplayMember displaymember; // Get attributes datasource = (UIListboxDatasource)context.PropertyDescriptor.Attributes[typeof(UIListboxDatasource)]; valuemember = (UIListboxValueMember)context.PropertyDescriptor.Attributes[typeof(UIListboxValueMember)]; displaymember = (UIListboxDisplayMember)context.PropertyDescriptor.Attributes[typeof(UIListboxDisplayMember)]; oList.BorderStyle = BorderStyle.None; oList.IntegralHeight = true; if (datasource != null) { oList.DataSource = datasource.Value; } if (displaymember != null) { oList.DisplayMember = displaymember.Value; } if (valuemember != null) { oList.ValueMember = valuemember.Value; } if (value != null) { if (value.GetType().Name == "String") { oList.Text = (string)value; } else { oList.SelectedItem = value; } } oList.SelectedIndexChanged += new System.EventHandler(this.SelectedItem); oEditorService.DropDownControl(oList); if (oList.SelectedIndices.Count == 1) { cp.SelectedItem = oList.SelectedItem; cp.SelectedValue = oSelectedValue; value = oList.Text; } oEditorService.CloseDropDown(); } else { return(base.EditValue(provider, value)); } return(value); }