Form component in VS toolbox - winforms

When I create a Component in VS it automatically appears in toolbox and can be used in design area of other components. However, when I create a Form (which also derives from Component) then I cannot add it to the toolbox.
Can this be changed so that a Form can be used as a Component?
If no, is there a specific reason why?

Related

Dropping Winforms components onto WPF window

I currently have some non-visual components that were written in Winforms. I added them to the toolbox, and can drag/drop them from the toolbox onto the form and it creates objects of that component to use. I was wondering if there was a way to drag/drop these Winforms created components onto a WPF app the same way? As of right now, the component is grayed out in the toolbox, and I have to manually add a reference to the .dll of the component. I then have to initialize the object in the code-behind manually.
Again, this is for a non-visual component. The reason I'm asking is because this is for a person that originally worked with Delphi and wants to be able to drag/drop components like that.

Is there something like master page in desktop aplications?

Can I have master form that will contain windows forms? Or even windows control?
Thanks a lot.
For a form to contain other forms, you want MDI (as Zach Johnson already said). Setting the relevant form properties (IsMdiContainer / MdiChildren / MdiParent / etc) will get you the behaviour you want.
For something like a "master page for forms", you could try using Visual Inheritance. First you define a basic "master" form layout, leaving space for the controls on the child forms. Then when you create new forms, be sure to select Add New-->Windows Forms-->Inherited Form, and Visual Studio will prompt you to select a parent form to inherit from.
You can achieve this with inheritance i suppose
I think you want to create a Multiple Document Interface (MDI). Also, all windows forms can contain controls, so you can by definition create a form that contains a control.
A winform application I work has a main form that is completely built in this manner. It uses one Winform and everything displayed on it is a user control. All the displays are written as plugins and can be pulled into the applications menu and have their user control displayed.

Multiple Forms in C# Window

I'm trying to build a simple application to test the idea of having multiple forms in one application. For example, in Visual Studio, you have the IDE - design area, and on the right hand side, you have a form called Properties and Solution Explorer
When you click on something in the design area, i.e. Textbox, on the right hand side, the properties for that object selected automatically changes.
I do not want to add the PropertyGrid ontop of the same form where the objects are, it must be independant on its own.
My ultimate goal is to have a 3D viewer/WPF and on the right hand side, a form. When you click in the 3D viewer on a line, or point, the selected object's properties must be displayed in the PropertyGrid
Second to that, I want to be able to dock the forms, or reset to default layout.
Screesnhot:
(properties should be docked inside the main form - not like screenshot)
Example: http://dan.virgesystems.com/images/CPVimage.JPG (Dead Link)
If you decide to do it using WinForms, there's a good C# opensource library for VS-style docking: http://sourceforge.net/projects/dockpanelsuite/
Here's a screenshot of an application using it: http://wiki.openstreetmap.org/wiki/Image:Kosmos.2.0.png
Try encapsulating your viewer and form into user controls. You can use the splitter control or panels to layout the container form as you please. Communication between the user controls can be done through events or direct references.

Component vs. Control

In the world of WinForms .Net controls
What is the difference between Component and Control?
Can a Control contains any Component?
Can a Component contains any Control?
A Control has all the plumbing required to act as a window. The ability to respond to Window messages (WndProc) and having a Handle being foremost. Component is missing all that. It is really rather simple, it has design time support to set properties and it can be disposed, that's all.
Components still can have a runtime representation, OpenFileDialog being the best example. But that is actually a dialog built into Windows, not Windows Forms.
A Component is just a representation of an object/sub API. eg. ImageList is a component which is invisible and is just an API into a set of images. The fact you can drag and drop them onto forms is just sugar in the designer.
A Control is intended to be visible/interactable/nestable.
In response to your comment, the Component and Control can be seen in the Object browser as being from different object hierarchies. A Component cannot be added within a Control, as the Controls collection only accepts objects with base type of Control.
A Component cannot contain Controls.
A component is basically a class (it can be a dll, Activex Object).
It does not have User Interface capabilities that's why you cannot see a visual representation.
It is portable and not specific to any language.
While on the other hand control is component which provides User Interface capabilities.
Since control has UI, you can see its visual representation.
It is language specific and not portable.

Master Form concept?

Like Master pages in ASP.NET, do we have any similar concept for Windows Form application. So that I dont have to repeat the same portion of form (Header and footer) many times through out the application.
Create a form class that defines the components you want, and make all your other forms a subclass of this form class.
Here is a good example in VB.NET.
That is what UserControls are for in Windows Forms.
Basically, you would create the "master" form and then the master form would be initialized with the types of the user controls that would go in the "placeholders". The form would just then create the controls given the Type instance(s) and add the instances to the Controls collection.
You can create a base form class with the controls that will be on every form of that type, and then derive all of your actual forms from that base class. This is called "Visual Inheritance", and the Windows Forms designer has some nice design-time support for this.
Alternatively, you might also look into the notion of having one actual form with your header and footer fields and a big blank panel where your individual "pages" will go. Make each page a user control and swap them in and out as needed at run-time. This is a standard way of making "wizard" dialogs, for example.

Resources