INFO: Code Sample That Demonstrates How to Create a Custom Form Designer by Using Visual C# .NET

Article translations Article translations
Article ID: 813808 - View products that this article applies to.
Expand all | Collapse all

SUMMARY

This article contains a code sample that demonstrates how to create a custom form designer by using Microsoft Visual C# .NET. Microsoft does not provide Microsoft Product Support Services or support hotfixes for this code sample.

MORE INFORMATION

To create a custom form designer, you must implement and use multiple interfaces. The sample code that this article contains illustrates the concepts that are involved in creating a custom form designer. The following are the two most important interfaces that you must implement:
  • IDesignerHost: This is defined in the System.ComponentModel.Design namespace.
  • IContainer: This is defined in the System.ComponentModel namespace.
Implement the IDesignerHost interface to provide support for designer transaction, for component management, and for retrieved designers.

When you implement the IContainer.Add method, see if the component that you are adding is the first component. If the component is the first component on your custom form designer, retrieve the corresponding IRootDesigner interface. If the component is not the first component on your custom form designer, retrieve the corresponding IDesigner interface. After you retrieve the appropriate interface (IDesigner or IRootDesigner), associate the retrieved designer with your custom form designer to provide the basic framework for your custom form designer. Then display your custom form designer. For more information, see the code sample and the associated documentation. Microsoft does not provide any support for the code sample.

The following file is available for download from the Microsoft Download Center:
Collapse this imageExpand this image
Download
Download the DesignerHost.exe package now. For additional information about how to download Microsoft Support files, click the following article number to view the article in the Microsoft Knowledge Base:
119591 How to Obtain Microsoft Support Files from Online Services
Microsoft scanned this file for viruses. Microsoft used the most current virus-detection software that was available on the date that the file was posted. The file is stored on security-enhanced servers that help to prevent any unauthorized changes to the file. To use this sample code, build, and then run DesignerHost.

REFERENCES

For more information about the IDesignerHost interface, visit the following Microsoft Developer Network (MSDN) Web site:
http://msdn2.microsoft.com/en-us/library/system.componentmodel.design.idesignerhost(vs.71).aspx
For more information about the IContainer interface, visit the following MSDN Web site:
http://msdn2.microsoft.com/en-us/library/system.componentmodel.icontainer(vs.71).aspx
For more information about the IRootDesigner interface, visit the following MSDN Web site:
http://msdn2.microsoft.com/en-us/library/system.componentmodel.design.irootdesigner(vs.71).aspx
For more information about the IDesigner interface, visit the following MSDN Web site:
http://msdn2.microsoft.com/en-us/library/system.componentmodel.design.idesigner(vs.71).aspx

Properties

Article ID: 813808 - Last Review: May 24, 2007 - Revision: 1.8
APPLIES TO
  • Microsoft .NET Framework 1.1
  • Microsoft .NET Framework 1.0
  • Microsoft Visual C# .NET 2003 Standard Edition
  • Microsoft Visual C# .NET 2002 Standard Edition
Keywords: 
kbdownload kbforms kbdesigner kbctrlcreate kbcompmodel kbcontrol kbwindowsforms kbprogramming kbsample kbcode kbinfo KB813808

Give Feedback

 

Contact us for more help

Contact us for more help
Connect with Answer Desk for expert help.
Get more support from smallbusiness.support.microsoft.com