Hi,
From your description you want to use an editor to edit a property of your custom composite control, right? If so you can either use the built-in Editor, like below, or write your own editor (if you want to do so please use reflector to view the source code of existing editor to see how to write it)
aspx:
<cc1:MyControl ID="MyControl1" runat="server">
<asp:ListItem>1</asp:ListItem>
<asp:ListItem>2</asp:ListItem>
<asp:ListItem>3</asp:ListItem>
</cc1:MyControl>
aspx.cs:
[ParseChildren(true, "Items")]
public class MyControl : CompositeControl
{
public MyControl() {
this.PreRender += new EventHandler(MyControl_PreRender);
}
void MyControl_PreRender(object sender, EventArgs e)
{
foreach (ListItem li in this.items)
{
TextBox tb = new TextBox() { Text = li.Text };
this.Controls.Add(tb);
}
}
private ListItemCollection items;
[DefaultValue((string)null),
PersistenceMode(PersistenceMode.InnerDefaultProperty),
Editor("System.Web.UI.Design.WebControls.ListItemsCollectionEditor,System.Design, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a",
typeof(UITypeEditor)), MergableProperty(false)]
public virtual ListItemCollection Items
{
get
{
if (this.items == null)
{
this.items = new ListItemCollection();
}
return this.items;
}
}
}