public ref class Control : System::ComponentModel::Component, System::ComponentModel::ISynchronizeInvoke, System::Windows::Forms::IWin32Window public ref class Control : System::ComponentModel::Component, IDisposable, System::ComponentModel::ISynchronizeInvoke, System::Windows::Forms::IBindableComponent, System::Windows::Forms::IDropTarget, System::Windows::Forms::IWin32Window public class Control : System.ComponentModel.Component, System.ComponentModel.ISynchronizeInvoke, System.Windows.Forms.IWin32Window [System.Runtime.InteropServices.ClassInterface(System.Runtime.InteropServices.ClassInterfaceType.AutoDispatch)] [System.Runtime.InteropServices.ComVisible(true)] public class Control : System.ComponentModel.Component, IDisposable, System.ComponentModel.ISynchronizeInvoke, System.Windows.Forms.IBindableComponent, System.Windows.Forms.IDropTarget, System.Windows.Forms.IWin32Window public class Control : System.ComponentModel.Component, IDisposable, System.ComponentModel.ISynchronizeInvoke, System.Windows.Forms.IBindableComponent, System.Windows.Forms.IDropTarget, System.Windows.Forms.IWin32Window type Control = class inherit Component interface UnsafeNativeMethods.IOleControl interface UnsafeNativeMethods.IOleObject interface UnsafeNativeMethods.IOleInPlaceObject interface UnsafeNativeMethods.IOleInPlaceActiveObject interface UnsafeNativeMethods.IOleWindow interface UnsafeNativeMethods.IViewObject interface UnsafeNativeMethods.IViewObject2 interface UnsafeNativeMethods.IPersist interface UnsafeNativeMethods.IPersistStreamInit interface UnsafeNativeMethods.IPersistPropertyBag interface UnsafeNativeMethods.IPersistStorage interface UnsafeNativeMethods.IQuickActivate interface ISynchronizeInvoke interface IWin32Window [<System.Runtime.InteropServices.ClassInterface(System.Runtime.InteropServices.ClassInterfaceType.AutoDispatch)>] [<System.Runtime.InteropServices.ComVisible(true)>] type Control = class inherit Component interface UnsafeNativeMethods.IOleControl interface UnsafeNativeMethods.IOleObject interface UnsafeNativeMethods.IOleInPlaceObject interface UnsafeNativeMethods.IOleInPlaceActiveObject interface UnsafeNativeMethods.IOleWindow interface UnsafeNativeMethods.IViewObject interface UnsafeNativeMethods.IViewObject2 interface UnsafeNativeMethods.IPersist interface UnsafeNativeMethods.IPersistStreamInit interface UnsafeNativeMethods.IPersistPropertyBag interface UnsafeNativeMethods.IPersistStorage interface UnsafeNativeMethods.IQuickActivate interface IDropTarget interface ISynchronizeInvoke interface IWin32Window interface IBindableComponent interface IComponent interface IDisposable [<System.Runtime.InteropServices.ClassInterface(System.Runtime.InteropServices.ClassInterfaceType.AutoDispatch)>] [<System.Runtime.InteropServices.ComVisible(true)>] type Control = class inherit Component interface IDropTarget interface ISynchronizeInvoke interface IWin32Window interface IBindableComponent interface IComponent interface IDisposable [<System.Runtime.InteropServices.ClassInterface(System.Runtime.InteropServices.ClassInterfaceType.AutoDispatch)>] [<System.Runtime.InteropServices.ComVisible(true)>] type Control = class inherit Component interface IDropTarget interface ISynchronizeInvoke interface IWin32Window interface IComponent interface IDisposable interface IBindableComponent [<System.Runtime.InteropServices.ClassInterface(System.Runtime.InteropServices.ClassInterfaceType.AutoDispatch)>] [<System.Runtime.InteropServices.ComVisible(true)>] type Control = class inherit Component interface UnsafeNativeMethods.IOleControl interface UnsafeNativeMethods.IOleObject interface UnsafeNativeMethods.IOleInPlaceObject interface UnsafeNativeMethods.IOleInPlaceActiveObject interface UnsafeNativeMethods.IOleWindow interface UnsafeNativeMethods.IViewObject interface UnsafeNativeMethods.IViewObject2 interface UnsafeNativeMethods.IPersist interface Interop.Ole32.IPersistStreamInit interface UnsafeNativeMethods.IPersistPropertyBag interface Interop.Ole32.IPersistStorage interface UnsafeNativeMethods.IQuickActivate interface IDropTarget interface ISynchronizeInvoke interface IWin32Window interface IComponent interface IDisposable interface IBindableComponent type Control = class inherit Component interface Interop.Ole32.IOleControl interface Interop.Ole32.IOleObject interface Interop.Ole32.IOleInPlaceObject interface Interop.Ole32.IOleInPlaceActiveObject interface Interop.Ole32.IOleWindow interface Interop.Ole32.IViewObject interface Interop.Ole32.IViewObject2 interface Interop.Ole32.IPersist interface Interop.Ole32.IPersistStreamInit interface Interop.Oleaut32.IPersistPropertyBag interface Interop.Ole32.IPersistStorage interface Interop.Ole32.IQuickActivate interface IDropTarget interface ISynchronizeInvoke interface IWin32Window interface IComponent interface IDisposable interface IBindableComponent Public Class Control Inherits Component Implements ISynchronizeInvoke, IWin32Window Public Class Control Inherits Component Implements IBindableComponent, IDisposable, IDropTarget, ISynchronizeInvoke, IWin32Window Inheritance Control DerivedSystem.ComponentModel.Design.ByteViewer System.Windows.Forms.AxHost System.Windows.Forms.ButtonBase System.Windows.Forms.DataGrid System.Windows.Forms.DataGridView AttributesClassInterfaceAttribute ComVisibleAttribute ImplementsISynchronizeInvoke IWin32Window IComponent IDisposable IBindableComponent IDropTarget To create your own control class, inherit from the UserControl, Control classes, or from the other Windows Forms provided controls. For more information about authoring custom controls, see Developing Custom Windows Forms Controls with the .NET Framework. The Control class implements very basic functionality required by classes that display information to the user. It handles user input through the keyboard and pointing devices. It handles message routing and security. It defines the bounds of a control (its position and size), although it does not implement painting. It provides a window handle (hWnd). Windows Forms controls use ambient properties so child controls can appear like their surrounding environment. An ambient property is a control property that, if not set, is retrieved from the parent control. If the control does not have a Parent, and the property is not set, the control attempts to determine the value of the ambient property through the Site property. If the control is not sited, if the site does not support ambient properties, or if the property is not set on the AmbientProperties, the control uses its own default values. Typically, an ambient property represents a characteristic of a control, such as BackColor, that is communicated to a child control. For example, a Button will have the same BackColor as its parent Form by default. Ambient properties provided by the Control class include: Cursor, Font, BackColor, ForeColor, and RightToLeft.
Note To make your Windows Forms application support visual styles, be sure to set the FlatStyle property to System and include a manifest with your executable. A manifest is an XML file that is included either as a resource within your application executable or as a separate file that resides in the same directory as the executable file. For an example of a manifest, see the Example section of the FlatStyle enumeration. For more information about using visual styles, see Visual Styles. Windows Forms has accessibility support built in, and provides information about your application that enables it to work with accessibility client applications such as screen enlarger and reviewer utilities, voice input utilities, on-screen keyboards, alternative input devices, and keyboard enhancement utilities. Sometimes you will want to provide additional information to accessibility client applications. There are two ways of providing this additional information. You can set the AccessibleName, AccessibleDescription, AccessibleDefaultActionDescription, and AccessibleRole property values, which will be reported to accessibility client applications. This method is typically used to provide limited accessibility information for existing controls. Alternatively, you can write your own class deriving from the AccessibleObject or Control.ControlAccessibleObject classes, providing as much accessibility information as needed.
Note To maintain better performance, do not set the size of a control in its constructor. The preferred method is to override the DefaultSize property.
Note Do not add data bindings for a Control in its constructor. Doing so will cause errors in code generation and can cause unwanted behavior. The majority of the controls in the System.Windows.Forms namespace use the underlying Windows common control as a base to build on. For more information about the Windows common controls, see General Control Reference. To identify Windows Forms controls from a separate process, use a standard SendMessage call to pass the WM_GETCONTROLNAME message. WM_GETCONTROLNAME is independent of the language and Windows hierarchy. For more information, see the "Recommended Solution for Windows Forms" topic in Automating Windows Forms. Use the InvokeRequired property to synchronize access to the control from multiple threads. For more information about multithreaded Windows Forms controls, see How to: Make Thread-Safe Calls to Windows Forms Controls Constructors
Properties
Methods
EventsExplicit Interface ImplementationsApplies toOnly the following members are thread safe: BeginInvoke(Delegate), EndInvoke(IAsyncResult), Invoke(Delegate), InvokeRequired, and CreateGraphics() if the handle for the control has already been created. Calling CreateGraphics() before the control's handle has been created on a background thread can cause illegal cross thread calls. See also
|