Q&A: What‘s the difference between CustomControl and UserControl?
来源:百度文库 编辑:神马文学网 时间:2024/03/28 17:29:32
Q&A: What‘s the difference between CustomControl and UserControl?
CustomControl:
[MSDN] 如果想要创建一个用于 Windows 窗体的完全自定义的控件,则要从 Control 类继承。尽管从 Control类继承对计划和实现有更高的要求,但它也使能够使用的选项最多。当从 Control继承时,就继承了使控件能够运行的最基本功能。 Control类的固有功能包括:处理用户通过键盘和鼠标的输入,定义控件的边界和大小,提供窗口句柄,以及提供信息处理和安全性。它不并入任何绘图(控件图形接口的实际呈现),也不并入任何特定用户交互功能。作者必须通过自定义代码提供所有这些功能。
UserControl:
[MSDN] 如果要使自定义代码和一个或多个 Windows 窗体控件的功能组合在一起,应该创建一个“用户控件”。用户控件将快速控件开发与标准 Windows窗体控件功能以及通过添加自定义属性和方法创建的多功能组合在一起。在创建用户控件时,系统会提供一个可视设计器,您可以将标准 Windows窗体控件置于该可视设计器中。这些控件保留了其所有固有功能以及标准控件的外观和感观,但是一旦将它们置于用户控件后,开发人员就不能通过代码使用它们。用户控件执行其自身的绘图工作,同时也处理与控件相关联的所有基本功能。
CustomControl:
[MSDN] 如果想要创建一个用于 Windows 窗体的完全自定义的控件,则要从 Control 类继承。尽管从 Control类继承对计划和实现有更高的要求,但它也使能够使用的选项最多。当从 Control继承时,就继承了使控件能够运行的最基本功能。 Control类的固有功能包括:处理用户通过键盘和鼠标的输入,定义控件的边界和大小,提供窗口句柄,以及提供信息处理和安全性。它不并入任何绘图(控件图形接口的实际呈现),也不并入任何特定用户交互功能。作者必须通过自定义代码提供所有这些功能。
UserControl:
[MSDN] 如果要使自定义代码和一个或多个 Windows 窗体控件的功能组合在一起,应该创建一个“用户控件”。用户控件将快速控件开发与标准 Windows窗体控件功能以及通过添加自定义属性和方法创建的多功能组合在一起。在创建用户控件时,系统会提供一个可视设计器,您可以将标准 Windows窗体控件置于该可视设计器中。这些控件保留了其所有固有功能以及标准控件的外观和感观,但是一旦将它们置于用户控件后,开发人员就不能通过代码使用它们。用户控件执行其自身的绘图工作,同时也处理与控件相关联的所有基本功能。
Q&A: What‘s the difference between CustomControl and UserControl?
What‘s the difference between JDK and ...
LMS and LCMS: What‘s the Difference?
LMS and LCMS: What‘s the Difference?
LMS and LCMS: What‘s the Difference?
The Difference between HDTV, EDTV, and SDTV
Methods GET and POST in HTML forms - what‘s the difference?
Methods GET and POST in HTML forms - what‘s the difference?
Difference between China and Western ...
What are the differences between boy and girl...
A breath of fresh air for relations between the U.S. and Latin America?
The link between murder and Mexico's GDP - FP...
A Contest between a Mortal and the Goddess of...
Culture Difference between China and Western .1111..
Culture Difference between China and Western ...3333
1Culture Difference between China and Western ...
Culture Difference between China and Western
Culture Difference between China and Western 2...
Culture 123Difference between China and Western ...
1234Culture Difference between China and Western ...
Culture Difference between China and Western ...bbbbbbbb
Culture Difference between China and Western ...56
Culture Difference between China and Western ...
Culture Difference between China and Western ...jghggh