コード例 #1
0
 [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));
 }
コード例 #2
0
 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);
 }
コード例 #3
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);
        }