首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > .NET > .NET >

如何获取属性窗口中的集合项-

2011-12-17 
怎么获取属性窗口中的集合项--[ToolboxItem(false)][ParseChildren(true)][Editor(typeof(SelectCommandCo

怎么获取属性窗口中的集合项--
[ToolboxItem(false)]
  [ParseChildren(true)]
  [Editor(typeof(SelectCommandCollectionEditor), typeof(UITypeEditor))]
  public class SelectCommandCollection:Collection<SearchSelect>
  {
  public SelectCommandCollection()
  :base()
  {}
  public new int Count{get{return base.Count;}}
  public bool IsReadOnly{get{return false;}}
  public new void Add(SearchSelect se){base.Add(se);}
  public new void Clear(){base.Clear();}
  public new bool Contains(SearchSelect se){return base.Contains(se);}
  public new bool Remove(SearchSelect se){return base.Remove(se);}
  public new SearchSelect this[int index]
  {
  get{return base[index];}
  set{base[index]=value;}
  }
  }
  [ToolboxItem(false)]
  [ParseChildren(true)]
  [Editor(typeof(OptionCommandCollectionEditor), typeof(UITypeEditor))]
  public class OptionCommandCollection : Collection<SearchOption>
  {
  public OptionCommandCollection() : base() { }
  public new int Count { get { return base.Count; } }
  public bool IsReadOnly { get { return false; } }
  public new void Add(SearchOption op) { base.Add(op); }
  public new void Clear() { base.Clear(); }
  public new bool Contains(SearchOption op) { return base.Contains(op); }
  public new bool Remove(SearchOption op) { return base.Remove(op); }
  public new SearchOption this[int index]
  {
  get { return base[index]; }
  set { base[index] = value; }
  }
  }
  public class SelectCommandCollectionEditor : CollectionEditor
  {
  public SelectCommandCollectionEditor(Type type) : base(type) { }
  protected override bool CanSelectMultipleInstances() { return true; }
  protected override Type[] CreateNewItemTypes()
  {
  return new Type[] { typeof(SearchSelect)};
  }
  protected override object CreateInstance(Type itemType)
  {
  if (itemType == typeof(SearchSelect)) { return new SearchSelect(); }
  return null;
  }

  }
  public class OptionCommandCollectionEditor : CollectionEditor
  {
  public OptionCommandCollectionEditor(Type type) : base(type) { }
  protected override bool CanSelectMultipleInstances() { return true; }
  protected override Type[] CreateNewItemTypes()
  {
  return new Type[] { typeof(SearchOption) };
  }
  protected override object CreateInstance(Type itemType)
  {
  if (itemType == typeof(SearchOption)) { return new SearchOption(); }
  return null;
  }

  }
  ///////////////////////////////////////////////
  public class ScriptItem
  {
  private string _Text;
  [DefaultValue("")]
  [Editor("System.ComponentModel.Design.MultilineStringEditor,System.Design", typeof(UITypeEditor))]
  [PersistenceMode(PersistenceMode.EncodedInnerDefaultProperty)]
  [NotifyParentProperty(true)]
  /// <summary> 
  /// JavaScript脚本块 
  /// </summary>     
  public string Text
  {
  get
  {


  return _Text;
  }
  set
  {
  _Text = value;
  }
  }

  }
  [ToolboxItem(false)]
  public class ScriptItemCollection : List<ScriptItem>
  {
  public ScriptItemCollection() : base() { }
  public ScriptItemCollection(int capacity) : base(capacity) { }
  public ScriptItemCollection(IEnumerable<ScriptItem> collection) : base(collection) { }
  }
  public class ScriptItemBuilder : ControlBuilder
  {
  public override Type GetChildControlType(string tagName, IDictionary attributes)
  {
  if (string.Compare(tagName.ToLower(), "scriptitem", false, CultureInfo.InvariantCulture) == 0)
  {
  return typeof(ScriptItem);
  }
  return null;
  }
  public override bool AllowWhitespaceLiterals()
  {
  return false;
  }
  }
 
  public class Search : Control{
  private SelectCommandCollection _SelectItems = new SelectCommandCollection();
  [PersistenceMode(PersistenceMode.InnerProperty)]
  [DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
  [Description("工具按钮集设置")]
  [Category("集合设置")]
  public SelectCommandCollection SelectItems
  {
  get
  {
  if (_SelectItems == null)
  {
  _SelectItems = new SelectCommandCollection();
  }
  return _SelectItems;
  }
  }
[color=#FF0000] public IList getIList()
  {?????????????????????????????????????????????????? }}
[/color]
问题说明。。
这是一个自定义控件中属性窗口的集合。
功能已经实现。。可以添加。但是就是不知道如何取得已经添加的值。并且转换成ILIST。


[解决办法]

热点排行