在設計階段開發 Windows Forms 控制項Develop Windows Forms controls at design time

針對控制項作者,.NET Framework 提供豐富的控制項撰寫技術。For control authors, the .NET Framework provides a wealth of control authoring technology. 作者不再只能設計作為預先存在之控制項集合的複合控制項。Authors are no longer limited to designing composite controls that act as a collection of preexisting controls. 透過繼承,您可以從預先存在的複合控制項或預先存在的 Windows Forms 控制項來建立自己的控制項。Through inheritance, you can create your own controls from preexisting composite controls or preexisting Windows Forms controls. 您也可以設計可實作自訂繪製的專屬控制項。You can also design your own controls that implement custom painting. 這些選項可提供視覺介面設計和功能的大量彈性。These options enable a great deal of flexibility to the design and functionality of the visual interface. 若要利用這些功能,您應該熟悉物件程式設計概念。To take advantage of these features, you should be familiar with object-based programming concepts.

注意

您不需要徹底瞭解繼承,但您可能會發現參考繼承基本概念(Visual Basic)很有説明。It is not necessary to have a thorough understanding of inheritance, but you may find it useful to refer to Inheritance basics (Visual Basic).

如果您想要建立自訂控制項以在 Web Forms 上使用,請參閱開發自訂 ASP.NET 伺服器控制項If you want to create custom controls to use on Web Forms, see Developing Custom ASP.NET Server Controls.

本節內容In this section

逐步解說:撰寫複合控制項Walkthrough: Authoring a Composite Control
示範如何在 C# 中建立簡單的複合控制項。Shows how to create a simple composite control in C#.

逐步解說:繼承自 Windows Forms 控制項Walkthrough: Inheriting from a Windows Forms Control
示範在 C# 中,如何使用繼承來建立簡單的 Windows Forms 控制項。Shows how to create a simple Windows Forms control using inheritance in C#.

逐步解說:使用設計工具動作執行一般工作Walkthrough: Perform common tasks using designer actions
示範如何在 Windows Forms 控制項上使用智慧標籤功能。Shows how to use the smart tag feature on Windows Forms controls.

逐步解說:使用 designerserializationvisibilityattribute 序列化\ 序列化標準類型的集合Walkthrough: Serializing Collections of Standard Types with the DesignerSerializationVisibilityAttribute</span> 示範如何使用 DesignerSerializationVisibilityAttribute.Content 屬性來序列化集合。Shows how to use the DesignerSerializationVisibilityAttribute.Content attribute to serialize a collection.

逐步解說:在設計階段針對自訂 Windows Forms 控制項進行偵錯Walkthrough: Debugging Custom Windows Forms Controls at Design Time
示範如何偵錯 Windows Forms 控制項的設計階段行為。Shows how to debug the design-time behavior of a Windows Forms control.

逐步解說:建立利用 Visual Studio 設計階段功能的 Windows Forms 控制項Walkthrough: Creating a Windows Forms Control That Takes Advantage of Visual Studio Design-Time Features
示範如何將複合控制項緊密整合至設計環境。Shows how to tightly integrate a composite control into the design environment.

如何:撰寫 Windows Forms 的控制項How to: Author Controls for Windows Forms
提供 Windows Forms 控制項實作考量的概觀。Provides an overview of considerations for implementing a Windows Forms control.

如何:撰寫複合控制項How to: Author Composite Controls
示範如何透過繼承自複合控制項來建立控制項。Shows how to create a control by inheriting from a composite control.

如何:繼承自 UserControl 類別How to: Inherit from the UserControl Class
提供如何建立複合控制項之程序的概觀。Provides an overview of the procedure for creating a composite control.

如何:繼承自現有的 Windows Forms 控制項How to: Inherit from Existing Windows Forms Controls
示範如何藉由繼承自 Button 控制項類別來建立擴充控制項。Shows how to create an extended control by inheriting from the Button control class.

如何:繼承自 Control 類別How to: Inherit from the Control Class
提供如何建立擴充控制項的概觀。Provides an overview of creating an extended control.

如何:在設計階段將控制項對齊表單邊緣How to: Align a Control to the Edges of Forms at Design Time
示範如何使用 [Dock] 屬性,將您的控制項對齊它所佔用表單的邊緣。Shows how to use the Dock property to align your control to the edge of the form it occupies.

如何:在選擇工具箱項目對話方塊中顯示控制項How to: Display a Control in the Choose Toolbox Items Dialog Box
示範如何安裝控制項的程序,讓它出現在 [自訂工具箱] 對話方塊中。Shows the procedure for installing your control so that it appears in the Customize Toolbox dialog box.

如何:為控制項提供工具箱點陣圖How to: Provide a Toolbox Bitmap for a Control
示範如何使用 [ToolboxBitmapAttribute],在 [工具箱] 中顯示自訂控制項旁邊的圖示。Shows how to use the ToolboxBitmapAttribute to display an icon next to your custom control in the Toolbox.

如何:測試 UserControl 的執行階段行為How to: Test the Run-Time Behavior of a UserControl
示範如何使用 [UserControl 測試容器] 來測試複合控制項的行為。Shows how to use the UserControl Test Container to test the behavior of a composite control.

Windows Forms 設計工具的設計階段錯誤Design-Time Errors in the Windows Forms Designer
說明 Windows Forms 設計工具載入失敗時,Microsoft Visual Studio 中所出現的設計階段錯誤清單的意義與使用。Explains the meaning and use of the Design-Time Error List that appears in Microsoft Visual Studio when the Windows Forms designer fails to load.

針對控制項和元件撰寫進行疑難排解Troubleshooting Control and Component Authoring
示範如何診斷和修正在您撰寫自訂元件或控制項時可能發生的常見問題。Shows how to diagnose and fix common issues that can occur when you author a custom component or control.

參考Reference

使用 .NET Framework 開發自訂的 Windows Forms 控制項Developing Custom Windows Forms Controls with the .NET Framework
討論如何使用 .NET Framework 建立您自己的自訂控制項。Discusses how to create your own custom controls with the .NET Framework.

語言獨立性以及與語言無關的元件Language Independence and Language-Independent Components
介紹設計目的是要簡化元件建立和使用的 Common Language Runtime。Introduces the common language runtime, which is designed to simplify the creation and use of components. 這個簡化的重要層面是使用不同程式設計語言所撰寫之元件之間增強的互通性。An important aspect of this simplification is enhanced interoperability between components written using different programming languages. Common Language Specification (CLS) 可讓您建立可處理多種程式設計語言的工具和元件。The Common Language Specification (CLS) makes it possible to create tools and components that work with multiple programming languages.

逐步解說:自動將自訂元件填入工具箱Walkthrough: Automatically Populating the Toolbox with Custom Components
描述如何讓元件或控制項顯示在 [自訂工具箱] 對話方塊中。Describes how to enable your component or control to be displayed in the Customize Toolbox dialog box.