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)));
 }
Beispiel #2
0
 private void BuildAttributes_ListboxEditor()
 {
     if (this.oDatasource != null)
     {
         UIListboxEditor.UIListboxDatasource    value  = new UIListboxEditor.UIListboxDatasource(ref this.oDatasource);
         UIListboxEditor.UIListboxValueMember   value2 = new UIListboxEditor.UIListboxValueMember(this.sValueMember);
         UIListboxEditor.UIListboxDisplayMember value3 = new UIListboxEditor.UIListboxDisplayMember(this.sDisplayMember);
         ArrayList arrayList = new ArrayList();
         arrayList.Add(value);
         arrayList.Add(value2);
         arrayList.Add(value3);
         if (this.bIsDropdownResizable)
         {
             UIListboxEditor.UIListboxIsDropDownResizable value4 = new UIListboxEditor.UIListboxIsDropDownResizable();
             arrayList.Add(value4);
         }
         Attribute[] attributes = (Attribute[])arrayList.ToArray(typeof(Attribute));
         this.oCustomAttributes = new AttributeCollection(attributes);
     }
 }
Beispiel #3
0
 private void BuildAttributes_ListboxEditor()
 {
     if (oDatasource != null)
     {
         UIListboxEditor.UIListboxDatasource    ds = new UIListboxEditor.UIListboxDatasource(ref oDatasource);
         UIListboxEditor.UIListboxValueMember   vm = new UIListboxEditor.UIListboxValueMember(sValueMember);
         UIListboxEditor.UIListboxDisplayMember dm = new UIListboxEditor.UIListboxDisplayMember(sDisplayMember);
         //UIListboxEditor.UIListboxIsDropDownResizable ddr = null;
         ArrayList attrs = new ArrayList();
         attrs.Add(ds);
         attrs.Add(vm);
         attrs.Add(dm);
         //if (bIsDropdownResizable)
         //{
         //    ddr = new UIListboxEditor.UIListboxIsDropDownResizable();
         //    attrs.Add(ddr);
         //}
         Attribute[] attrArray;
         attrArray         = (System.Attribute[])attrs.ToArray(typeof(Attribute));
         oCustomAttributes = new AttributeCollection(attrArray);
     }
 }
Beispiel #4
0
 private void BuildAttributes_ListboxEditor()
 {
     if (oDatasource != null)
     {
         UIListboxEditor.UIListboxDatasource ds = new UIListboxEditor.UIListboxDatasource(ref oDatasource);
         UIListboxEditor.UIListboxValueMember vm = new UIListboxEditor.UIListboxValueMember(sValueMember);
         UIListboxEditor.UIListboxDisplayMember dm = new UIListboxEditor.UIListboxDisplayMember(sDisplayMember);
         UIListboxEditor.UIListboxIsDropDownResizable ddr = null;
         ArrayList attrs = new ArrayList();
         attrs.Add(ds);
         attrs.Add(vm);
         attrs.Add(dm);
         if (bIsDropdownResizable)
         {
             ddr = new UIListboxEditor.UIListboxIsDropDownResizable();
             attrs.Add(ddr);
         }
         Attribute[] attrArray;
         attrArray =  (System.Attribute[]) attrs.ToArray(typeof(Attribute));
         oCustomAttributes = new AttributeCollection(attrArray);
     }
 }