Note that there are some explanatory texts on larger screens.

plurals
  1. POUser Control as container at design time
    primarykey
    data
    text
    <p>I'm designing a simple expander control.</p> <p>I've derived from UserControl, drawn inner controls, built, run; all ok.</p> <p>Since an inner Control is a Panel, I'd like to use it as container at design time. Indeed I've used the attributes:</p> <pre><code>[Designer(typeof(ExpanderControlDesigner))] [Designer("System.Windows.Forms.Design.ParentControlDesigner, System.Design", typeof(IDesigner))] </code></pre> <p>Great I say. But it isn't...</p> <p>The result is that I can use it as container at design time but:</p> <ul> <li>The added controls go back the inner controls already embedded in the user control</li> <li>Even if I push to top a control added at design time, at runtime it is back again on controls embedded to the user control</li> <li>I cannot restrict the container area at design time into a Panel area</li> </ul> <p>What am I missing? Here is the code for completeness... why this snippet of code is not working?</p> <pre><code>[Designer(typeof(ExpanderControlDesigner))] [Designer("System.Windows.Forms.Design.ParentControlDesigner, System.Design", typeof(IDesigner))] public partial class ExpanderControl : UserControl { public ExpanderControl() { InitializeComponent(); .... [System.Security.Permissions.PermissionSet(System.Security.Permissions.SecurityAction.Demand, Name = "FullTrust")] internal class ExpanderControlDesigner : ControlDesigner { private ExpanderControl MyControl; public override void Initialize(IComponent component) { base.Initialize(component); MyControl = (ExpanderControl)component; // Hook up events ISelectionService s = (ISelectionService)GetService(typeof(ISelectionService)); IComponentChangeService c = (IComponentChangeService)GetService(typeof(IComponentChangeService)); s.SelectionChanged += new EventHandler(OnSelectionChanged); c.ComponentRemoving += new ComponentEventHandler(OnComponentRemoving); } private void OnSelectionChanged(object sender, System.EventArgs e) { } private void OnComponentRemoving(object sender, ComponentEventArgs e) { } protected override void Dispose(bool disposing) { ISelectionService s = (ISelectionService)GetService(typeof(ISelectionService)); IComponentChangeService c = (IComponentChangeService)GetService(typeof(IComponentChangeService)); // Unhook events s.SelectionChanged -= new EventHandler(OnSelectionChanged); c.ComponentRemoving -= new ComponentEventHandler(OnComponentRemoving); base.Dispose(disposing); } public override System.ComponentModel.Design.DesignerVerbCollection Verbs { get { DesignerVerbCollection v = new DesignerVerbCollection(); v.Add(new DesignerVerb("&amp;asd", new EventHandler(null))); return v; } } } </code></pre> <p>I've found many resources (<a href="https://stackoverflow.com/questions/2293082/interactive-design-time-user-control">Interaction</a>, <a href="https://stackoverflow.com/questions/1927400/design-time-moving-of-a-child-control-owned-by-a-composite-user-control">designed</a>, <a href="https://stackoverflow.com/questions/375430/how-to-restrict-client-control-area-in-a-custom-winforms-control">limited area</a>), but nothing was usefull for being operative...</p> <p><em>Actually there is a trick, since System.Windows.Forms classes can be designed (as usual) and have a correct behavior at runtime (TabControl, for example).</em></p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload