The following example overrides the AppendSubBuilder method to throw an Exception if the control this control builder is applied to tries to include controls in its instance of ControlCollection class.
// Override the AppendSubBuilder method to throw an // exception if the class it is applied to attempts // to include child controls. publicoverridevoid AppendSubBuilder(ControlBuilder subBuilder)
"A custom label control cannot contain other objects.");
Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)