public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value) { if (context != null) { if (provider != null) { if (context.Instance != null) { this.oEditorService = (IWindowsFormsEditorService)provider.GetService(typeof(IWindowsFormsEditorService)); if (this.oEditorService != null) { CustomProperty.CustomPropertyDescriptor customPropertyDescriptor = (CustomProperty.CustomPropertyDescriptor)context.PropertyDescriptor; CustomProperty customProperty = (CustomProperty)customPropertyDescriptor.CustomProperty; PropertyDescriptor propertyDescriptor = context.PropertyDescriptor; UIListboxEditor.UIListboxDatasource uIListboxDatasource = (UIListboxEditor.UIListboxDatasource)propertyDescriptor.Attributes[typeof(UIListboxEditor.UIListboxDatasource)]; UIListboxEditor.UIListboxValueMember uIListboxValueMember = (UIListboxEditor.UIListboxValueMember)propertyDescriptor.Attributes[typeof(UIListboxEditor.UIListboxValueMember)]; UIListboxEditor.UIListboxDisplayMember uIListboxDisplayMember = (UIListboxEditor.UIListboxDisplayMember)propertyDescriptor.Attributes[typeof(UIListboxEditor.UIListboxDisplayMember)]; ListBox oList = this.oList; oList.BorderStyle = BorderStyle.None; oList.IntegralHeight = true; if (uIListboxDatasource != null) { oList.DataSource = RuntimeHelpers.GetObjectValue(uIListboxDatasource.Value); } if (uIListboxDisplayMember != null) { oList.DisplayMember = uIListboxDisplayMember.Value; } if (uIListboxValueMember != null) { oList.ValueMember = uIListboxValueMember.Value; } if (value != null) { if (Operators.CompareString(value.GetType().Name, "String", false) == 0) { this.oList.Text = Conversions.ToString(value); } else { this.oList.SelectedItem = RuntimeHelpers.GetObjectValue(value); } } this.oList.SelectedIndexChanged += new EventHandler(this.SelectedItem); this.oEditorService.DropDownControl(this.oList); if (this.oList.SelectedIndices.Count == 1) { customProperty.SelectedItem = RuntimeHelpers.GetObjectValue(this.oList.SelectedItem); customProperty.SelectedValue = RuntimeHelpers.GetObjectValue(this.oSelectedValue); value = this.oList.Text; } this.oEditorService.CloseDropDown(); return(value); } return(base.EditValue(provider, RuntimeHelpers.GetObjectValue(value))); } } } return(base.EditValue(provider, RuntimeHelpers.GetObjectValue(value))); }
[RefreshProperties(RefreshProperties.All)] public override object EditValue(ITypeDescriptorContext context, System.IServiceProvider provider, object value) { if (context == null || provider == null || context.Instance == null) { return(base.EditValue(provider, value)); } if (m_MethodDelegate == null) { DelegateAttribute attr = (DelegateAttribute)context.PropertyDescriptor.Attributes[typeof(DelegateAttribute)]; m_MethodDelegate = attr.GetMethod; } if (m_sender == null) { m_sender = context.PropertyDescriptor as CustomProperty.CustomPropertyDescriptor; } return(m_MethodDelegate.Invoke(m_sender, null)); }
public override object EditValue(ITypeDescriptorContext context, System.IServiceProvider provider, object value) { if (context == null || provider == null || context.Instance == null) { return base.EditValue(provider, value); } if (m_MethodDelegate == null) { DelegateAttribute attr = (DelegateAttribute) context.PropertyDescriptor.Attributes[typeof(DelegateAttribute)]; m_MethodDelegate = attr.GetMethod; } if (m_sender == null) { m_sender = context.PropertyDescriptor as CustomProperty.CustomPropertyDescriptor; } return m_MethodDelegate.Invoke(m_sender, null); }
public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value) { if (context != null) { if (provider != null) { if (context.Instance != null) { if (this.m_MethodDelegate == null) { UICustomEventEditor.DelegateAttribute delegateAttribute = (UICustomEventEditor.DelegateAttribute)context.PropertyDescriptor.Attributes[typeof(UICustomEventEditor.DelegateAttribute)]; this.m_MethodDelegate = delegateAttribute.GetMethod; } if (this.m_sender == null) { this.m_sender = (context.PropertyDescriptor as CustomProperty.CustomPropertyDescriptor); } return(this.m_MethodDelegate(this.m_sender, null)); } } } return(base.EditValue(provider, RuntimeHelpers.GetObjectValue(value))); }
[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); }