Exposing a collection properties

  • Thread starter Thiago H M Fernandes [BrDevelopers]
  • Start date
T

Thiago H M Fernandes [BrDevelopers]

Hi all,
I am trying to create a control that expose a collection of a custom class.
I did some like this:

// My Custom Button
[TypeConverter(typeof(ExpandableObjectConverter))]
public class HTMLEditorButton : Image {}

// My Collection of Custom Buttons
public class HTMLEditorButtonCollection : CollectionBase {}

[ParseChildren(true, "ToolBarButtons")]
[Designer(typeof(HTMLEditorServerControlDesign))]
[DefaultProperty("ToolBarButtons")]
public class HTMLEditorServerControl : WebControl, INamingContainer
{
private HTMLEditorButtonCollection toolBarButtons;

//Constructor
public HTMLEditorServerControl()
{
toolBarButtons = new HTMLEditorButtonCollection();
}

//Property
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
[PersistenceModeAttribute(PersistenceMode.InnerDefaultProperty)]
[MergableProperty(false)]
[NotifyParentPropertyAttribute(true)]
[Description("Tool bar control's collection.")]
[Category("ToolBar")]
public HTMLEditorButtonCollection ToolBarButtons
{
get { return this.toolBarButtons; }
}

// Methods
protected override void CreateChildControls()
{
Controls.Clear();

if(toolBarButtons ==null)
toolBarButtons = new HTMLEditorButtonCollection();

Controls.Add(toolBarButtons);
}

protected override void Render(HtmlTextWriter writer)
{
EnsureChildControls();
RenderContents(writer);
}

}

The problem is, when I run the HTMLEditorButton added at design-time doesn't
apear at runtime. I tryed Google's search and MSDN but I can't found anything.

If some one could help me or give me a link to an article I will aprettiate.

Thanks,
Thiago H M Fernandes
 
T

Thiago H M Fernandes [BrDevelopers]

Hi all again,
After a help from a brazilian community called BrDevelopers
(www.brdevelopers.net), I got the solution:

Just change this:

[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]

for this:

[DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]


Thanks all,
Thiago H M Fernandes
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,905
Latest member
Kristy_Poole

Latest Threads

Top