private void FillDataSourceList()
        {
            this._dataSourceBox.Items.Clear();
            IComponent             component  = this.GetComponent();
            PropertyDescriptor     descriptor = TypeDescriptor.GetProperties(component)["DataSourceID"];
            TypeConverter          converter  = descriptor.Converter;
            ITypeDescriptorContext context    = new TypeDescriptorContext(component);

            foreach (string str in (IEnumerable)converter.GetStandardValues(context))
            {
                this._dataSourceBox.Items.Add(str);
            }
            string dataSourceID = this.Control.DataSourceID;

            if (dataSourceID.Length > 0)
            {
                int index = this._dataSourceBox.Items.IndexOf(dataSourceID);
                if (index > -1)
                {
                    this._dataSourceBox.SelectedIndex = index;
                }
                else
                {
                    this._dataSourceBox.SelectedIndex = this._dataSourceBox.Items.Add(dataSourceID);
                }
            }
            else
            {
                this._dataSourceBox.SelectedIndex = this._dataSourceBox.Items.IndexOf(System.Design.SR.GetString("DataSourceIDChromeConverter_NoDataSource"));
            }
        }
 private void FillDataSourceList()
 {
     this._dataSourceBox.Items.Clear();
     IComponent component = this.GetComponent();
     PropertyDescriptor descriptor = TypeDescriptor.GetProperties(component)["DataSourceID"];
     TypeConverter converter = descriptor.Converter;
     ITypeDescriptorContext context = new TypeDescriptorContext(component);
     foreach (string str in (IEnumerable) converter.GetStandardValues(context))
     {
         this._dataSourceBox.Items.Add(str);
     }
     string dataSourceID = this.Control.DataSourceID;
     if (dataSourceID.Length > 0)
     {
         int index = this._dataSourceBox.Items.IndexOf(dataSourceID);
         if (index > -1)
         {
             this._dataSourceBox.SelectedIndex = index;
         }
         else
         {
             this._dataSourceBox.SelectedIndex = this._dataSourceBox.Items.Add(dataSourceID);
         }
     }
     else
     {
         this._dataSourceBox.SelectedIndex = this._dataSourceBox.Items.IndexOf(System.Design.SR.GetString("DataSourceIDChromeConverter_NoDataSource"));
     }
 }
コード例 #3
0
ファイル: DualListDesigner.cs プロジェクト: vijaymca/Dotnet
        private bool EditItemsCallback(object context)
        {
            ListItemsCollectionEditor itemsEditor = new ListItemsCollectionEditor(typeof(ListItemCollection));

            IDesignerHost designerHost = (IDesignerHost)this.GetService(typeof(IDesignerHost));
            PropertyDescriptor editedProperty = (PropertyDescriptor)context;

            ITypeDescriptorContext typeDescriptorContext = new TypeDescriptorContext(designerHost, editedProperty, base.Component);

            IServiceProvider serviceProvider = new WindowsFormsEditorService(this);

            itemsEditor.EditValue(typeDescriptorContext, serviceProvider, editedProperty.GetValue(base.Component));
            return true;
        }