Windows Form multiple designer for a control - c#

I made a custom designer for a control. The problem is that the base class has a designer, too. Since it's marked as internal, I can't inherit from it. Is there a way to force the designer to use multiple designers for a control?

Related

C# custom Windows Forms base class and designer

I am trying to implement the GUI part of a plug-in, which means that I have to inherit from a custom base class (which inherits from UserControl) included with the plugin assembly.
When implementing my own control, I would normally inherit from UserControl and going to the designer would be really straightforward (just double clicking on the solution explorer).
In order to be able to work with the designer, I do a first implementation using UserControl as base class.
The problem is that as soon as I change the base class into ApplicantTabControlPlugin (the custom base class provided by the plugin), I cannot open the designer for this control anymore. I.e., if I close the designer, it seems it is gone forever.
Is there any way to prevent this behaviour?
You should add
<SubType>Component</SubType>
to the project file entry of your base class.

Designer.cs file not generated on sub-classing a subclass of System.Windows.Form

I had a Form "ParentForm" Designed in C# VS2010 with two buttons.
I wanted five forms to have the same two buttons, so i decided to write five *.cs files(subForm1.cs,subForm2.cs...subForm5.cs) derived from the "ParentForm" as base class.
Now VS2010 shows these derived classes with a form icon(ie recognizes as Forms), but does not generate a .designer.cs file for it. So the problem I am facing is that, whenever I drag a
Control into derived class form say subForm1.cs , VS2010 puts the auto-generated code into my subForm1.cs instead of subForm1.Designer.cs. Although I tried manually creating a file named subForm1.Designer.cs (which also gets detected and is put under the hierarchy of the Form icon in solution explorer) but, still the auto-generated code goes to the subForm1.cs file. How do
I tell VS2010 to patch subForm1.cs+subForm1.Designer.cs+subForm1.resx as one form subForm1.
If you want to have the designer file, Add new Windows Forms.
Then replace the inheritance from Form class to your ParentForm class.
This way any new controls you add to your child form should get added in the designer file.
Also please go through this link on Visual Inheritance

Share a (container)control from a (custom)control?

Soo... I am making a control like the Windows Update "panels".
Everything's fine up to the "container" part.
What I want to do is to allow the designer to place controls in a Panel which is inside my control.
(The panel's variable is held in my control's class and inside the control itself.)
How do I bypass this?
As a reference, you might want to try out this AeroWizard Control, which does this pretty well.
(Yes, I have looked at it and didn't find a clue but custom designers!)
As a side note, I'd rather not make a complicated designer class...
If you don't want to create a custom designer class, you should implement your control as a templated custom control, preferably inheriting from CompositeControl.
There doesn't seem to be a way to do the same in Windows Forms without a custom designer class. However, there's a nice, short, working example of such a designer here.

Visual Studio 2008: Adding components to inherited panel

In this scenario I have a base component with a close button and a flow panel; (FlowLayoutPanel) the idea being that components extending this add their controls to the flow panel and will have the close button functionality done for them.
The problem is that I can't seem to persuade VS to add the components in the subclassed component to the flow panel; this ends up with me having to do so in the code. Which is all well and good except that it won't show up in the designer view. If I add it to the partial class with the designer generated code then I can see the controls in the designer view laid out by the flow panel. But this just gets overwritten afterwards.
Visual Studio doesn't seem to let you dock controls in inherited panels - unless I'm doing something wrong? I did make sure that the base panel is publically visible in case this was the issue.
--
An alternative might be some way to persuade the designer to execute/not overwrite my code in the designer class.
You need to make a ControlDesigner for your control and override the InternalControlDesigner and GetParentForComponent methods.
For an example, open System.Windows.Forms.Design.SplitContainerDesigner (in System.Design.dll in Reflector.

VS 05 - Designer Attributes and Component Designer. How are they related?

I had this answer on another post I asked:
"I believe the VS designer does it [components of a menustrip/statusstrip] by getting an instance of the control's designer (see the Designer attribute), and, if the designer is a ComponentDesigner, getting the AssociatedComponents property."
How do I do this? I'm not even sure where to begin...
The DesignerAttribute attribute can be attached to a Control or Component class in WinForms to indicate the class that implements a designer for visually editing that type of control or component. For example, the Form class has a DesignerAttribute that indicates a class called FormDocumentDesigner implements its designer.
Designers allow special design-time behavior to be applied in the WinForms designer in Visual Studio such as list view column resizing or the sizing handles on controls. Designers that support the addition of child controls to an existing control, such as FormDocumentDesigner are ultimately derived from ComponentDesigner.
You can check this out by using a tool like .NET Reflector.

Categories

Resources