【发布时间】:2010-03-06 07:07:09
【问题描述】:
WinForms 应用程序中显示的所有窗口和控件(包括 active-x)是否都派生自 System.Windows.Forms.Control 类?
【问题讨论】:
WinForms 应用程序中显示的所有窗口和控件(包括 active-x)是否都派生自 System.Windows.Forms.Control 类?
【问题讨论】:
基本上是的。
但是,Timers 等非可视组件是从 Component 派生的(或实现 IComponent)。只有 Button 和 Form 等视觉元素是从 Control 派生的。
此外,ActiveX 控件本身并不是从 Control 派生的,因为它们是 COM 组件;相反,当您导入 ActiveX 控件时,Visual Studio 会生成一个派生自 AxHost 并承载 COM 对象的包装器。 (AxHost 本身确实派生自 Control。)
【讨论】:
我觉得你应该看看
http://msdn.microsoft.com/en-us/library/aa651811(VS.71).aspx
继承层次结构
系统..::.Object
System..::.MarshalByRefObject
System.ComponentModel..::.Component System.Windows.Forms..::.Control System.Windows.Forms..::.AxHost System.Windows.Forms..::.ButtonBase System.Windows.Forms..::.DataGrid System.Windows.Forms..::.DataGridView System.Windows.Forms..::.DateTimePicker System.Windows.Forms..::.GroupBox System.Windows.Forms.Integration..::.ElementHost System.Windows.Forms..::.Label System.Windows.Forms..::.ListControl System.Windows.Forms..::.ListView System.Windows.Forms..::.MdiClient System.Windows.Forms..::.MonthCalendar System.Windows.Forms..::.PictureBox System.Windows.Forms..::.PrintPreviewControl System.Windows.Forms..::.ProgressBar System.Windows.Forms..::.ScrollableControl System.Windows.Forms..::.ScrollBar System.Windows.Forms..::.Splitter System.Windows.Forms..::.StatusBar System.Windows.Forms..::.TabControl System.Windows.Forms..::.TextBoxBase System.Windows.Forms..::.ToolBar System.Windows.Forms..::.TrackBar System.Windows.Forms..::.TreeView System.Windows.Forms..::.WebBrowserBase
【讨论】: