自定义控件的绘制和呈现Custom Control Painting and Rendering

自定义绘制的控件是可轻松在.NET Framework 的许多复杂任务之一。Custom painting of controls is one of the many complicated tasks made easy by the .NET Framework. 在创作时自定义控件,有许多种有关控件的图形外观。When authoring a custom control, you have many options regarding your control's graphical appearance. 如果创作继承的控件Control,必须提供代码,使您的控件来呈现其图形表示形式。If you are authoring a control that inherits from the Control, you must provide code that allows your control to render its graphical representation. 如果通过继承创建用户控件UserControl,继承或从一个 Windows 窗体控件,可以忽略在标准的图形表示形式,并提供你自己的图形代码。If you are creating a user control by inheriting from the UserControl, or are inheriting from one of the Windows Forms controls, you may override the standard graphical representation and provide your own graphics code. 如果你想要提供的构成控件的自定义呈现UserControl创作,你的选项变得更为有限,但仍允许范围广泛的控件和应用程序的图形化可能性。If you want to provide custom rendering for the constituent controls of a UserControl you are authoring, your options become more limited, but still allow a wide range of graphical possibilities for your controls and applications.

本节内容In This Section

呈现 Windows 窗体控件Rendering a Windows Forms Control
演示如何编写显示一个控件的逻辑。Shows how to program the logic that displays a control.

用户绘制的控件User-Drawn Controls
概述在编写和重写为您的控件的呈现代码中所涉及的步骤。Gives an overview of the steps involved in writing and overriding rendering code for your control.

构成控件Constituent Controls
介绍如何在你的用户控件和窗体中实现的构成控件的自定义呈现代码。Describes how to implement custom rendering code for constituent controls in your user controls and forms.

如何:使控件在运行时不可见How to: Make Your Control Invisible at Run Time
演示如何使用Visible隐藏和显示控件的属性。Shows how to use the Visible property to hide and show a control.

如何:使控件拥有透明背景How to: Give Your Control a Transparent Background
演示如何使用SetStyle方法来创建不透明、 透明或部分透明的背景颜色。Shows how to use the SetStyle method to create a background color that is opaque, transparent, or partially transparent.

使用视觉样式呈现控件Rendering Controls with Visual Styles
演示如何呈现支持它们的操作系统中使用视觉样式的控件。Shows how to render controls using visual styles in operating systems that support them.

参考Reference

Control
对此类进行描述,并提供指向其所有成员的链接。Describes this class and has links to all of its members.

UserControl
对此类进行描述,并提供指向其所有成员的链接。Describes this class and has links to all of its members.

OnPaint
介绍了此方法。Describes this method.

如何:创建用于绘制图形对象How to: Create Graphics Objects for Drawing
从 Visual Studio 的角度介绍 GDI + 图形功能,并提供详细信息链接。Introduces GDI+ graphics functionality from a Visual Studio perspective and gives links to more information.

各种自定义控件Varieties of Custom Controls
描述可以创作自定义控件的类型。Describes the kinds of custom controls you can author.