public override void SetProperty(DesignerPropertyInfo property, object obj)
        {
            base.SetProperty(property, obj);

            object[] excludedElements = null;
            string   enumName         = string.Empty;
            Type     enumtype         = null;

            DesignerEnum enumAtt = property.Attribute as DesignerEnum;

            if (enumAtt != null)
            {
                excludedElements = enumAtt.ExcludedElements;
                enumName         = Enum.GetName(property.Property.PropertyType, property.Property.GetValue(obj, null));
                enumtype         = property.Property.PropertyType;
            }

            DesignerFlexibleEnum flexEnumAtt = property.Attribute as DesignerFlexibleEnum;

            if (flexEnumAtt != null)
            {
                excludedElements = flexEnumAtt.ExcludedElements;

                FlexiblePropertyEnum flexProp = (FlexiblePropertyEnum)property.Property.GetValue(obj, null);
                enumName = Enum.GetName(flexProp.EnumType, flexProp.Value);
                enumtype = flexProp.EnumType;
            }

            if (enumtype == null)
            {
                throw new Exception(string.Format(Resources.ExceptionDesignerAttributeExpectedEnum, property.Property.Name));
            }

            Array list = Enum.GetValues(enumtype);

            foreach (object enumVal in list)
            {
                bool excluded = false;

                if (excludedElements != null)
                {
                    for (int i = 0; i < excludedElements.Length; ++i)
                    {
                        if (excludedElements[i].Equals(enumVal))
                        {
                            excluded = true;
                            break;
                        }
                    }
                }

                if (!excluded)
                {
                    comboBox.Items.Add(Enum.GetName(enumtype, enumVal));
                    _values.Add(enumVal);
                }
            }

            comboBox.Text = enumName;
        }
        private void comboBox_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (!_valueWasAssigned)
            {
                return;
            }

            if (_property.Attribute is DesignerEnum)
            {
                _property.Property.SetValue(_object, _values[comboBox.SelectedIndex], null);
            }

            if (_property.Attribute is DesignerFlexibleEnum)
            {
                FlexiblePropertyEnum flexProp = (FlexiblePropertyEnum)_property.Property.GetValue(_object, null);
                flexProp.Value = (int)_values[comboBox.SelectedIndex];
            }

            OnValueChanged();
        }